Class: Angband::Documentation

Inherits:
Object
  • Object
show all
Defined in:
lib/angband/documentation.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) {|_self| ... } ⇒ Documentation

Returns a new instance of Documentation.

Yields:

  • (_self)

Yield Parameters:



7
8
9
10
# File 'lib/angband/documentation.rb', line 7

def initialize(app)
  @app = app
  yield self if block_given?
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/angband/documentation.rb', line 12

def call(env)
  response = Rack::AcceptHeaders.new(@app).call(env)

  if options_request?(env) && successful?(response) && !cross_origin_request?(env)
    features  = Angband::GherkinFinder.new(@files).call(env['PATH_INFO'])
    formatter = Angband::Formatter.new(env['rack-accept_headers.request'])

    headers, content = formatter.call(features)
    response[1].merge!(headers)
    response[2] = [content]
  end

  response
end

#configure(files) ⇒ Object



27
28
29
# File 'lib/angband/documentation.rb', line 27

def configure(files)
  @files = files
end