Class: Gherkin::Listener::FormatterListener::Stash

Inherits:
Object
  • Object
show all
Defined in:
lib/gherkin/listener/formatter_listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStash

Returns a new instance of Stash.



94
95
96
97
# File 'lib/gherkin/listener/formatter_listener.rb', line 94

def initialize
  @comments, @tags, @ids = [], [], []
  @row_index = 0
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



92
93
94
# File 'lib/gherkin/listener/formatter_listener.rb', line 92

def comments
  @comments
end

#idsObject (readonly)

Returns the value of attribute ids.



92
93
94
# File 'lib/gherkin/listener/formatter_listener.rb', line 92

def ids
  @ids
end

#tagsObject (readonly)

Returns the value of attribute tags.



92
93
94
# File 'lib/gherkin/listener/formatter_listener.rb', line 92

def tags
  @tags
end

Instance Method Details

#comment(comment) ⇒ Object



99
100
101
# File 'lib/gherkin/listener/formatter_listener.rb', line 99

def comment(comment)
  @comments << comment
end

#examples(name) {|@comments, @tags, @examples_id| ... } ⇒ Object

Yields:



115
116
117
118
119
120
# File 'lib/gherkin/listener/formatter_listener.rb', line 115

def examples(name)
  @examples_id = "#{@feature_element_id};#{id(name)}"
  @row_index = 0
  yield @comments, @tags, @examples_id
  @comments, @tags = [], []
end

#feature(name) {|@comments, @tags, @feature_id| ... } ⇒ Object

Yields:



103
104
105
106
107
# File 'lib/gherkin/listener/formatter_listener.rb', line 103

def feature(name)
  @feature_id = id(name)
  yield @comments, @tags, @feature_id
  @comments, @tags = [], []
end

#feature_element(name) {|@comments, @tags, @feature_element_id| ... } ⇒ Object

Yields:



109
110
111
112
113
# File 'lib/gherkin/listener/formatter_listener.rb', line 109

def feature_element(name)
  @feature_element_id = "#{@feature_id};#{id(name)}"
  yield @comments, @tags, @feature_element_id
  @comments, @tags = [], []
end

#id(name) ⇒ Object



138
139
140
# File 'lib/gherkin/listener/formatter_listener.rb', line 138

def id(name)
  (name || '').gsub(/[\s_]/, '-').downcase
end

#row {|@comments, defined?(@examples_id) ? "#{@examples_id};#{@row_index}" : :undefined_examples_id| ... } ⇒ Object

Yields:

  • (@comments, defined?(@examples_id) ? "#{@examples_id};#{@row_index}" : :undefined_examples_id)


128
129
130
131
132
# File 'lib/gherkin/listener/formatter_listener.rb', line 128

def row
  @row_index += 1
  yield @comments, defined?(@examples_id) ? "#{@examples_id};#{@row_index}" : :undefined_examples_id
  @comments = []
end

#step {|@comments| ... } ⇒ Object

Yields:



122
123
124
125
126
# File 'lib/gherkin/listener/formatter_listener.rb', line 122

def step
  @row_index += 1
  yield @comments
  @comments = []
end

#tag(tag) ⇒ Object



134
135
136
# File 'lib/gherkin/listener/formatter_listener.rb', line 134

def tag(tag)
  @tags << tag
end