class Gherkin::Listener::FormatterListener
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).
Public Class Methods
new(formatter)
click to toggle source
# File lib/gherkin/listener/formatter_listener.rb, line 12 def initialize(formatter) @formatter = formatter @stash = Stash.new end
Public Instance Methods
background(keyword, name, description, line)
click to toggle source
# 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
comment(value, line)
click to toggle source
# File lib/gherkin/listener/formatter_listener.rb, line 17 def comment(value, line) @stash.comment Formatter::Model::Comment.new(value, line) end
doc_string(content_type, value, line)
click to toggle source
# 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
eof()
click to toggle source
# File lib/gherkin/listener/formatter_listener.rb, line 75 def eof replay_step_or_examples @formatter.eof end
examples(keyword, name, description, line)
click to toggle source
# 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
feature(keyword, name, description, line)
click to toggle source
# 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
row(cells, line)
click to toggle source
# 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
scenario(keyword, name, description, line)
click to toggle source
# 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
scenario_outline(keyword, name, description, line)
click to toggle source
# 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
step(keyword, name, line)
click to toggle source
# 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
syntax_error(state, ev, legal_events, uri, line)
click to toggle source
# 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
tag(name, line)
click to toggle source
# File lib/gherkin/listener/formatter_listener.rb, line 21 def tag(name, line) @stash.tag Formatter::Model::Tag.new(name, line) end
Private Instance Methods
replay(element)
click to toggle source
# File lib/gherkin/listener/formatter_listener.rb, line 86 def replay(element) element.replay(@formatter) end
replay_step_or_examples()
click to toggle source
# 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