Adapter from the “raw” Gherkin
Listener
API to the slightly more high-level
Formatter
API, which is easier to implement (less state to
keep track of).
# File lib/gherkin/listener/formatter_listener.rb, line 12 def initialize(formatter) @formatter = formatter @comments = [] @tags = [] @table = nil end
# File lib/gherkin/listener/formatter_listener.rb, line 31 def background(keyword, name, description, line) @formatter.background(Formatter::Model::Background.new(grab_comments!, keyword, name, description, line)) end
# File lib/gherkin/listener/formatter_listener.rb, line 19 def comment(value, line) @comments << Formatter::Model::Comment.new(value, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 60 def doc_string(string, content_type, line) @doc_string = Formatter::Model::DocString.new(string, content_type, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 64 def eof replay_step_or_examples @formatter.eof end
# File lib/gherkin/listener/formatter_listener.rb, line 45 def examples(keyword, name, description, line) replay_step_or_examples @examples_statement = Formatter::Model::Examples.new(grab_comments!, grab_tags!, keyword, name, description, line, nil) end
# File lib/gherkin/listener/formatter_listener.rb, line 27 def feature(keyword, name, description, line) @formatter.feature(Formatter::Model::Feature.new(grab_comments!, grab_tags!, keyword, name, description, line)) end
# File lib/gherkin/listener/formatter_listener.rb, line 55 def row(cells, line) @table ||= [] @table << Formatter::Model::Row.new(grab_comments!, cells, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 35 def scenario(keyword, name, description, line) replay_step_or_examples @formatter.scenario(Formatter::Model::Scenario.new(grab_comments!, grab_tags!, keyword, name, description, line)) end
# File lib/gherkin/listener/formatter_listener.rb, line 40 def scenario_outline(keyword, name, description, line) replay_step_or_examples @formatter.scenario_outline(Formatter::Model::ScenarioOutline.new(grab_comments!, grab_tags!, keyword, name, description, line)) end
# File lib/gherkin/listener/formatter_listener.rb, line 50 def step(keyword, name, line) replay_step_or_examples @step_statement = Formatter::Model::Step.new(grab_comments!, keyword, name, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 69 def syntax_error(state, ev, legal_events, uri, line) @formatter.syntax_error(state, ev, legal_events, uri, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 23 def tag(name, line) @tags << Formatter::Model::Tag.new(name, line) end