Class: Rack::Jspm
- Inherits:
-
Object
- Object
- Rack::Jspm
- Defined in:
- lib/rack/jspm.rb,
lib/rack/jspm/version.rb
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #cache_control ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Jspm
constructor
A new instance of Jspm.
- #max_age ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Jspm
Returns a new instance of Jspm.
8 9 10 11 |
# File 'lib/rack/jspm.rb', line 8 def initialize(app, = {}) @app = app @options = { max_age: 3600 }.merge() end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/rack/jspm.rb', line 6 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/rack/jspm.rb', line 6 def @options end |
Instance Method Details
#cache_control ⇒ Object
26 27 28 |
# File 'lib/rack/jspm.rb', line 26 def cache_control { 'Cache-Control' => "max-age=#{max_age}, public" } end |
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/rack/jspm.rb', line 13 def call(env) status, headers, body = @app.call(env) case env['PATH_INFO'] when %r{/jspm_packages/[^/]+/} headers = headers.merge(cache_control) end [status, headers, body] end |
#max_age ⇒ Object
22 23 24 |
# File 'lib/rack/jspm.rb', line 22 def max_age .fetch(:max_age) end |