Class: RhetButler::Web::AssetsApp
- Inherits:
-
Object
- Object
- RhetButler::Web::AssetsApp
- Defined in:
- lib/rhet-butler/web/assets-app.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AssetsContext
Instance Attribute Summary collapse
-
#file_manager ⇒ Object
readonly
Returns the value of attribute file_manager.
Instance Method Summary collapse
- #assets_context ⇒ Object
- #call(env) ⇒ Object
-
#initialize(file_manager) ⇒ AssetsApp
constructor
A new instance of AssetsApp.
- #template_handler ⇒ Object
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_manager ⇒ Object (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_context ⇒ Object
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_handler ⇒ Object
25 26 27 |
# File 'lib/rhet-butler/web/assets-app.rb', line 25 def template_handler file_manager.base_assets(::Tilt::Cache.new) end |