class RhetButler::Web::AssetsApp

Attributes

file_manager[R]

Public Class Methods

new(file_manager) click to toggle source
# File lib/rhet-butler/web/assets-app.rb, line 4
def initialize(file_manager)
  @file_manager = file_manager
end

Public Instance Methods

assets_context() click to toggle source
# File lib/rhet-butler/web/assets-app.rb, line 29
def assets_context
  AssetsContext.new(template_handler)
end
call(env) click to toggle source
# File lib/rhet-butler/web/assets-app.rb, line 33
def call(env)
  asset_path = env["PATH_INFO"]
  asset_path.sub!(/^\//,"")
  extension = asset_path.sub(/.*[.]/, ".")

  mime_type = Rack::Mime.mime_type(extension, "text/plain")
  [200, {'Content-Type' => mime_type}, [assets_context.render(asset_path)]]
rescue Object => ex
  puts ex
  raise
end
template_handler() click to toggle source
# File lib/rhet-butler/web/assets-app.rb, line 25
def template_handler
  file_manager.base_assets(::Tilt::Cache.new)
end