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 @stash = Stash.new end
# File lib/gherkin/listener/formatter_listener.rb, line 31 def background(keyword, name, description, line) @stash.feature_element(name) do |comments, tags, id| replay Formatter::Model::Background.new(comments, keyword, name, description, line) end end
# File lib/gherkin/listener/formatter_listener.rb, line 17 def comment(value, line) @stash.comment Formatter::Model::Comment.new(value, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 71 def doc_string(content_type, value, line) @current_builder.doc_string(value, content_type, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 75 def eof replay_step_or_examples @formatter.eof end
# File lib/gherkin/listener/formatter_listener.rb, line 51 def examples(keyword, name, description, line) replay_step_or_examples @stash.examples(name) do |comments, tags, id| @current_builder = Formatter::Model::Examples::Builder.new(comments, tags, keyword, name, description, line, id) end end
# File lib/gherkin/listener/formatter_listener.rb, line 25 def feature(keyword, name, description, line) @stash.feature(name) do |comments, tags, id| replay Formatter::Model::Feature.new(comments, tags, keyword, name, description, line, id) end end
# File lib/gherkin/listener/formatter_listener.rb, line 65 def row(cells, line) @stash.basic_statement do |comments, id| @current_builder.row(comments, cells, line, id) end end
# File lib/gherkin/listener/formatter_listener.rb, line 37 def scenario(keyword, name, description, line) replay_step_or_examples @stash.feature_element(name) do |comments, tags, id| replay Formatter::Model::Scenario.new(comments, tags, keyword, name, description, line, id) end end
# File lib/gherkin/listener/formatter_listener.rb, line 44 def scenario_outline(keyword, name, description, line) replay_step_or_examples @stash.feature_element(name) do |comments, tags, id| replay Formatter::Model::ScenarioOutline.new(comments, tags, keyword, name, description, line, id) end end
# File lib/gherkin/listener/formatter_listener.rb, line 58 def step(keyword, name, line) replay_step_or_examples @stash.basic_statement do |comments, id| @current_builder = Formatter::Model::Step::Builder.new(comments, keyword, name, line) end end
# File lib/gherkin/listener/formatter_listener.rb, line 80 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 21 def tag(name, line) @stash.tag Formatter::Model::Tag.new(name, line) end
# File lib/gherkin/listener/formatter_listener.rb, line 86 def replay(element) element.replay(@formatter) end
# File lib/gherkin/listener/formatter_listener.rb, line 136 def replay_step_or_examples return unless @current_builder replay(@current_builder) @current_builder = nil end