Parent

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
12:       def initialize(formatter)
13:         @formatter = formatter
14:         @comments = []
15:         @tags = []
16:         @table = nil
17:       end

Public Instance Methods

background(keyword, name, description, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 31
31:       def background(keyword, name, description, line)
32:         @formatter.background(Formatter::Model::Background.new(grab_comments!, keyword, name, description, line))
33:       end
comment(value, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 19
19:       def comment(value, line)
20:         @comments << Formatter::Model::Comment.new(value, line)
21:       end
eof() click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 64
64:       def eof
65:         replay_step_or_examples
66:         @formatter.eof
67:       end
examples(keyword, name, description, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 45
45:       def examples(keyword, name, description, line)
46:         replay_step_or_examples
47:         @examples_statement = Formatter::Model::Examples.new(grab_comments!, grab_tags!, keyword, name, description, line)
48:       end
feature(keyword, name, description, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 27
27:       def feature(keyword, name, description, line)
28:         @formatter.feature(Formatter::Model::Feature.new(grab_comments!, grab_tags!, keyword, name, description, line))
29:       end
py_string(string, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 60
60:       def py_string(string, line)
61:         @py_string = Formatter::Model::PyString.new(string, line)
62:       end
row(cells, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 55
55:       def row(cells, line)
56:         @table ||= []
57:         @table << Formatter::Model::Row.new(grab_comments!, cells, line)
58:       end
scenario(keyword, name, description, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 35
35:       def scenario(keyword, name, description, line)
36:         replay_step_or_examples
37:         @formatter.scenario(Formatter::Model::Scenario.new(grab_comments!, grab_tags!, keyword, name, description, line))
38:       end
scenario_outline(keyword, name, description, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 40
40:       def scenario_outline(keyword, name, description, line)
41:         replay_step_or_examples
42:         @formatter.scenario_outline(Formatter::Model::ScenarioOutline.new(grab_comments!, grab_tags!, keyword, name, description, line))
43:       end
step(keyword, name, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 50
50:       def step(keyword, name, line)
51:         replay_step_or_examples
52:         @step_statement = Formatter::Model::Step.new(grab_comments!, keyword, name, nil, line)
53:       end
syntax_error(state, ev, legal_events, uri, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 69
69:       def syntax_error(state, ev, legal_events, uri, line)
70:         @formatter.syntax_error(state, ev, legal_events, uri, line)
71:       end
tag(name, line) click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 23
23:       def tag(name, line)
24:         @tags << Formatter::Model::Tag.new(name, line)
25:       end

Private Instance Methods

grab_comments!() click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 75
75:       def grab_comments!
76:         comments = @comments
77:         @comments = []
78:         comments
79:       end
grab_py_string!() click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 93
93:       def grab_py_string!
94:         py_string = @py_string
95:         @py_string = nil
96:         py_string
97:       end
grab_rows!() click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 87
87:       def grab_rows!
88:         table = @table
89:         @table = nil
90:         table
91:       end
grab_tags!() click to toggle source
    # File lib/gherkin/listener/formatter_listener.rb, line 81
81:       def grab_tags!
82:         tags = @tags
83:         @tags = []
84:         tags
85:       end
replay_step_or_examples() click to toggle source
     # File lib/gherkin/listener/formatter_listener.rb, line 99
 99:       def replay_step_or_examples
100:         if(@step_statement)
101:           @step_statement.multiline_arg = grab_py_string! || grab_rows!
102:           @formatter.step(@step_statement)
103:           @step_statement = nil
104:         end
105:         if(@examples_statement)
106:           @examples_statement.rows = grab_rows!
107:           @formatter.examples(@examples_statement)
108:           @examples_statement = nil
109:         end
110:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.