Class: Rack::Pygmoku

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/rack/pygmoku.rb,
lib/rack/pygmoku/version.rb

Defined Under Namespace

Modules: Version

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ Pygmoku

Returns a new instance of Pygmoku.



8
9
10
11
# File 'lib/rack/pygmoku.rb', line 8

def initialize(app, opts = {})
  @app  = app
  @opts = default_opts.merge(opts)
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rack/pygmoku.rb', line 13

def call(env)
  status, headers, response = @app.call(env)
  headers = HeaderHash.new(headers)

  if highlight?(status, headers)
    content = highlight(response.join)
    headers['Content-Length'] = bytesize(content).to_s
    response = [content]
  end

  [status, headers, response]
end