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.



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

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

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



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

def comments
  @comments
end

#idsObject (readonly)

Returns the value of attribute ids.



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

def ids
  @ids
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

Instance Method Details

#basic_statement {|@comments, "#{@examples_id};#{@row_index}"| ... } ⇒ Object

Yields:

  • (@comments, "#{@examples_id};#{@row_index}")


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

def basic_statement
  @row_index += 1
  yield @comments, "#{@examples_id};#{@row_index}"
  @comments = []
end

#comment(comment) ⇒ Object



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

def comment(comment)
  @comments << comment
end

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

Yields:



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

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:



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

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:



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

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

#id(name) ⇒ Object



131
132
133
# File 'lib/gherkin/listener/formatter_listener.rb', line 131

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

#tag(tag) ⇒ Object



127
128
129
# File 'lib/gherkin/listener/formatter_listener.rb', line 127

def tag(tag)
  @tags << tag
end