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.
- #location(feature_uri) ⇒ Object
- #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
35 36 37 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 35 def background(keyword, name, description, line) @formatter.background(statement(grab_comments!, [], keyword, name, description, line)) end |
#comment(value, line) ⇒ Object
23 24 25 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 23 def comment(value, line) @comments << Formatter::Model::Comment.new(value, line) end |
#eof ⇒ Object
68 69 70 71 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 68 def eof replay_step_or_examples @formatter.eof end |
#examples(keyword, name, description, line) ⇒ Object
49 50 51 52 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 49 def examples(keyword, name, description, line) replay_step_or_examples @examples_statement = statement(grab_comments!, , keyword, name, description, line) end |
#feature(keyword, name, description, line) ⇒ Object
31 32 33 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 31 def feature(keyword, name, description, line) @formatter.feature(statement(grab_comments!, , keyword, name, description, line), @feature_uri) end |
#location(feature_uri) ⇒ Object
19 20 21 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 19 def location(feature_uri) @feature_uri = feature_uri end |
#py_string(string, line) ⇒ Object
64 65 66 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 64 def py_string(string, line) @py_string = Formatter::Model::PyString.new(string, line) end |
#row(cells, line) ⇒ Object
59 60 61 62 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 59 def row(cells, line) @table ||= [] @table << Formatter::Model::Row.new(grab_comments!, cells, line) end |
#scenario(keyword, name, description, line) ⇒ Object
39 40 41 42 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 39 def scenario(keyword, name, description, line) replay_step_or_examples @formatter.scenario(statement(grab_comments!, , keyword, name, description, line)) end |
#scenario_outline(keyword, name, description, line) ⇒ Object
44 45 46 47 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 44 def scenario_outline(keyword, name, description, line) replay_step_or_examples @formatter.scenario_outline(statement(grab_comments!, , keyword, name, description, line)) end |
#step(keyword, name, line) ⇒ Object
54 55 56 57 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 54 def step(keyword, name, line) replay_step_or_examples @step_statement = statement(grab_comments!, [], keyword, name, nil, line) end |
#syntax_error(state, ev, legal_events, uri, line) ⇒ Object
73 74 75 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 73 def syntax_error(state, ev, legal_events, uri, line) @formatter.syntax_error(state, ev, legal_events, uri, line) end |