Class: Rack::AvvoIgnite
- Inherits:
-
Object
- Object
- Rack::AvvoIgnite
- Defined in:
- lib/rack/avvo_ignite.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ AvvoIgnite
constructor
A new instance of AvvoIgnite.
Constructor Details
#initialize(app, options = {}) ⇒ AvvoIgnite
Returns a new instance of AvvoIgnite.
4 5 6 7 8 |
# File 'lib/rack/avvo_ignite.rb', line 4 def initialize(app, = {}) @app = app @ignite_host = [:host] || "ia.avvo.com" @tracker_code = [:code] end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rack/avvo_ignite.rb', line 10 def call(env) status, headers, response = @app.call(env) if headers['Content-Type'].to_s.include?('text/html') # Only update HTML bodies response.each do |part| if part.rindex('</body>') part.gsub!('</body>', + '</body>') headers['Content-Length'] = (headers['Content-Length'].to_i + .length).to_s end end end [status, headers, response] end |