Class: Rack::StaticAssets
- Inherits:
-
Object
- Object
- Rack::StaticAssets
- Includes:
- Utils
- Defined in:
- lib/rack/static-assets.rb
Constant Summary collapse
- FORMAT =
%{%s - [%s] [%s] "%s %s%s %s" (%s) %d %d %0.4f\n}
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ StaticAssets
constructor
A new instance of StaticAssets.
Constructor Details
#initialize(app, opts = {}) ⇒ StaticAssets
Returns a new instance of StaticAssets.
12 13 14 15 16 17 |
# File 'lib/rack/static-assets.rb', line 12 def initialize(app, opts = {}) @app = app @opts = { :assets => "http://www.google.com/jsapi" } @opts.merge! opts end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rack/static-assets.rb', line 19 def call(env) began_at = Time.now status, headers, response = @app.call(env) headers = HeaderHash.new(headers) if !STATUS_WITH_NO_ENTITY_BODY.include?(status) && !headers['transfer-encoding'] && headers['content-type'] && headers['content-type'].include?("text/html") content = "" response.each { |part| content += part } doc = Hpricot(content) # nodes = doc.search(@opts[:element]) # nodes.each do |node| # s = node.inner_html || "[++where is the code?++]" # node.parent.swap(send(@highlighter, s)) # end body = doc.to_html # headers['content-length'] = body.bytesize.to_s headers.delete('content-length') # will be set by Rack::ContentLength log(env, status, headers, began_at) if @opts[:logging] [status, headers, [body]] else [status, headers, response] end end |