Class: RhetButler::Web::AssetsApp

Inherits:
Object
  • Object
show all
Defined in:
lib/rhet-butler/web/assets-app.rb

Direct Known Subclasses

MemoizedAssetsApp

Defined Under Namespace

Classes: AssetsContext

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_manager) ⇒ AssetsApp

Returns a new instance of AssetsApp.



4
5
6
# File 'lib/rhet-butler/web/assets-app.rb', line 4

def initialize(file_manager)
  @file_manager = file_manager
end

Instance Attribute Details

#file_managerObject (readonly)

Returns the value of attribute file_manager.



8
9
10
# File 'lib/rhet-butler/web/assets-app.rb', line 8

def file_manager
  @file_manager
end

Instance Method Details

#assets_contextObject



29
30
31
# File 'lib/rhet-butler/web/assets-app.rb', line 29

def assets_context
  AssetsContext.new(template_handler)
end

#call(env) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# 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_handlerObject



25
26
27
# File 'lib/rhet-butler/web/assets-app.rb', line 25

def template_handler
  file_manager.base_assets(::Tilt::Cache.new)
end