Class: Gherkin::Listener::FormatterListener
- Inherits:
-
Object
- Object
- Gherkin::Listener::FormatterListener
- Defined in:
- lib/gherkin/listener/formatter_listener.rb
Overview
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).
Instance Method Summary collapse
- #background(keyword, name, description, line) ⇒ Object
- #comment(value, line) ⇒ Object
- #eof ⇒ Object
- #examples(keyword, name, description, line) ⇒ Object
- #feature(keyword, name, description, line) ⇒ Object
-
#initialize(formatter) ⇒ FormatterListener
constructor
A new instance of FormatterListener.
- #py_string(string, line) ⇒ Object
- #row(cells, line) ⇒ Object
- #scenario(keyword, name, description, line) ⇒ Object
- #scenario_outline(keyword, name, description, line) ⇒ Object
- #step(keyword, name, line) ⇒ Object
- #syntax_error(state, ev, legal_events, uri, line) ⇒ Object
- #tag(name, line) ⇒ Object
Constructor Details
#initialize(formatter) ⇒ FormatterListener
Returns a new instance of FormatterListener.
12 13 14 15 16 17 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 12 def initialize(formatter) @formatter = formatter @comments = [] @tags = [] @table = nil end |
Instance Method Details
#background(keyword, name, description, line) ⇒ Object
31 32 33 |
# 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 |
#comment(value, line) ⇒ Object
19 20 21 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 19 def comment(value, line) @comments << Formatter::Model::Comment.new(value, line) end |
#eof ⇒ Object
64 65 66 67 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 64 def eof replay_step_or_examples @formatter.eof end |
#examples(keyword, name, description, line) ⇒ Object
45 46 47 48 |
# 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!, , keyword, name, description, line) end |
#feature(keyword, name, description, line) ⇒ Object
27 28 29 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 27 def feature(keyword, name, description, line) @formatter.feature(Formatter::Model::Feature.new(grab_comments!, , keyword, name, description, line)) end |
#py_string(string, line) ⇒ Object
60 61 62 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 60 def py_string(string, line) @py_string = Formatter::Model::PyString.new(string, line) end |
#row(cells, line) ⇒ Object
55 56 57 58 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 55 def row(cells, line) @table ||= [] @table << Formatter::Model::Row.new(grab_comments!, cells, line) end |
#scenario(keyword, name, description, line) ⇒ Object
35 36 37 38 |
# 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!, , keyword, name, description, line)) end |
#scenario_outline(keyword, name, description, line) ⇒ Object
40 41 42 43 |
# 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!, , keyword, name, description, line)) end |
#step(keyword, name, line) ⇒ Object
50 51 52 53 |
# 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 |
#syntax_error(state, ev, legal_events, uri, line) ⇒ Object
69 70 71 |
# 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 |