Class: Rack::Xrevision
- Inherits:
-
Object
- Object
- Rack::Xrevision
- Defined in:
- lib/rack/xrevision.rb,
lib/rack/xrevision/version.rb
Constant Summary collapse
- REVISION_FILE_NAME =
'REVISION'
- VERSION =
'0.1'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Xrevision
constructor
A new instance of Xrevision.
- #rev_id ⇒ Object
- #revision_file_path ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Xrevision
Returns a new instance of Xrevision.
4 5 6 7 8 |
# File 'lib/rack/xrevision.rb', line 4 def initialize(app, ={}) @app = app @app_path = [:app_path] || Dir.pwd @revision_file_name = [:file_name] || REVISION_FILE_NAME end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 |
# File 'lib/rack/xrevision.rb', line 10 def call(env) status, headers, response = @app.call(env) headers['X-Rev'] = rev_id if rev_id [status, headers, response] end |
#rev_id ⇒ Object
16 17 18 19 20 |
# File 'lib/rack/xrevision.rb', line 16 def rev_id @rev_id ||= begin load_from_file || load_from_git end end |
#revision_file_path ⇒ Object
22 23 24 |
# File 'lib/rack/xrevision.rb', line 22 def revision_file_path "#{@app_path}/#{@revision_file_name}" end |