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).
Defined Under Namespace
Classes: Stash
Instance Method Summary collapse
- #background(keyword, name, description, line) ⇒ Object
- #comment(value, line) ⇒ Object
- #doc_string(content_type, 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.
- #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 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 12 def initialize(formatter) @formatter = formatter @stash = Stash.new @current_builder = nil end |
Instance Method Details
#background(keyword, name, description, line) ⇒ Object
32 33 34 35 36 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 32 def background(keyword, name, description, line) @stash.feature_element(name) do |comments, , id| replay Formatter::Model::Background.new(comments, keyword, name, description, line) end end |
#comment(value, line) ⇒ Object
18 19 20 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 18 def comment(value, line) @stash.comment Formatter::Model::Comment.new(value, line) end |
#doc_string(content_type, value, line) ⇒ Object
72 73 74 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 72 def doc_string(content_type, value, line) @current_builder.doc_string(value, content_type, line) end |
#eof ⇒ Object
76 77 78 79 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 76 def eof replay_step_or_examples @formatter.eof end |
#examples(keyword, name, description, line) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 52 def examples(keyword, name, description, line) replay_step_or_examples @stash.examples(name) do |comments, , id| @current_builder = Formatter::Model::Examples::Builder.new(comments, , keyword, name, description, line, id) end end |
#feature(keyword, name, description, line) ⇒ Object
26 27 28 29 30 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 26 def feature(keyword, name, description, line) @stash.feature(name) do |comments, , id| replay Formatter::Model::Feature.new(comments, , keyword, name, description, line, id) end end |
#row(cells, line) ⇒ Object
66 67 68 69 70 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 66 def row(cells, line) @stash.row do |comments, id| @current_builder.row(comments, cells, line, id) end end |
#scenario(keyword, name, description, line) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 38 def scenario(keyword, name, description, line) replay_step_or_examples @stash.feature_element(name) do |comments, , id| replay Formatter::Model::Scenario.new(comments, , keyword, name, description, line, id) end end |
#scenario_outline(keyword, name, description, line) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 45 def scenario_outline(keyword, name, description, line) replay_step_or_examples @stash.feature_element(name) do |comments, , id| replay Formatter::Model::ScenarioOutline.new(comments, , keyword, name, description, line, id) end end |
#step(keyword, name, line) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 59 def step(keyword, name, line) replay_step_or_examples @stash.step do |comments| @current_builder = Formatter::Model::Step::Builder.new(comments, keyword, name, line) end end |
#syntax_error(state, ev, legal_events, uri, line) ⇒ Object
81 82 83 |
# File 'lib/gherkin/listener/formatter_listener.rb', line 81 def syntax_error(state, ev, legal_events, uri, line) @formatter.syntax_error(state, ev, legal_events, uri, line) end |