Class: Cucumber::Ast::Tags
Overview
Holds the names of tags parsed from a feature file:
@invoice @release_2
This gets stored internally as ["invoice", "release_2"]
Class Method Summary collapse
-
.strip_prefix(tag_name) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #accept_hook?(hook) ⇒ Boolean
- #count(tag) ⇒ Object
-
#initialize(line, tag_names) ⇒ Tags
constructor
A new instance of Tags.
- #to_sexp ⇒ Object
Constructor Details
#initialize(line, tag_names) ⇒ Tags
Returns a new instance of Tags.
14 15 16 |
# File 'lib/cucumber/ast/tags.rb', line 14 def initialize(line, tag_names) @line, @tag_names = line, tag_names end |
Class Method Details
.strip_prefix(tag_name) ⇒ Object
:nodoc:
10 11 12 |
# File 'lib/cucumber/ast/tags.rb', line 10 def self.strip_prefix(tag_name) tag_name =~ /^@(.*)/ ? $1 : tag_name end |
Instance Method Details
#accept(visitor) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/cucumber/ast/tags.rb', line 18 def accept(visitor) return if $cucumber_interrupted @tag_names.each do |tag_name| visitor.visit_tag_name(tag_name) end end |
#accept_hook?(hook) ⇒ Boolean
25 26 27 |
# File 'lib/cucumber/ast/tags.rb', line 25 def accept_hook?(hook) hook.tag_names.empty? || (hook.tag_names.map{|tag| Ast::Tags.strip_prefix(tag)} & @tag_names).any? end |
#count(tag) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/cucumber/ast/tags.rb', line 29 def count(tag) # See discussion: # http://github.com/weplay/cucumber/commit/2dc592acdf3f7c1a0c333a8164649936bb82d983 if @tag_names.respond_to?(:count) && @tag_names.method(:count).arity > 0 @tag_names.count(tag) # 1.9 else @tag_names.select{|t| t == tag}.length # 1.8 end end |
#to_sexp ⇒ Object
39 40 41 |
# File 'lib/cucumber/ast/tags.rb', line 39 def to_sexp @tag_names.map{|tag_name| [:tag, tag_name]} end |