Class: Rack::Usermanual

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/rack/usermanual/app.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(app, options) ⇒ Usermanual

Returns a new instance of Usermanual.



12
13
14
15
16
17
# File 'lib/rack/usermanual/app.rb', line 12

def initialize(app, options)
  super(app)
  @sections = options[:sections]
  @index = options[:index]
  @main_views = options[:views]
end

Instance Method Details

#get_feature(path, page) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rack/usermanual/app.rb', line 52

def get_feature(path, page)
  sio = StringIO.new
  json_formatter = Gherkin::Formatter::JSONFormatter.new(sio)
  parser = Gherkin::Parser::Parser.new(json_formatter)
  filepath = "#{path}/#{page}.feature"
  halt 404 unless ::File.exist?(filepath)
  raw = ::File.read(filepath)
  parser.parse(raw, uri, 0)
  json_formatter.done
  [raw, JSON.parse(sio.string)]
end