Class: Rack::Unscripted

Inherits:
Object
  • Object
show all
Defined in:
lib/version.rb,
lib/rack/unscripted.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(app, warning_message = nil) ⇒ Unscripted

Returns a new instance of Unscripted.



3
4
5
6
# File 'lib/rack/unscripted.rb', line 3

def initialize(app, warning_message = nil)
  self.warning_message = warning_message if warning_message
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/rack/unscripted.rb', line 8

def call(env)
  @status, @headers, @response = @app.call(env)
  if valid_content_type?(@headers['Content-Type']) && valid_status?(@status)
    @response.each do |response_line|
      insert_js(response_line)   if response_line =~ head_regex
      insert_html(response_line) if response_line =~ body_regex
    end
  end
  [@status, @headers, @response]
end