Class: Gherkin::Listener::FormatterListener

Inherits:
Object
  • Object
show all
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

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

#eofObject



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!, grab_tags!, 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!, grab_tags!, 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!, grab_tags!, 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!, grab_tags!, 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

#tag(name, line) ⇒ Object



23
24
25
# File 'lib/gherkin/listener/formatter_listener.rb', line 23

def tag(name, line)
  @tags << Formatter::Model::Tag.new(name, line)
end