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"]
Constant Summary collapse
- EXCLUDE_PATTERN =
/^~/
Instance Attribute Summary collapse
-
#tag_names ⇒ Object
readonly
Returns the value of attribute tag_names.
Class Method Summary collapse
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.
41 42 43 |
# File 'lib/cucumber/ast/tags.rb', line 41 def initialize(line, tag_names) @line, @tag_names = line, tag_names end |
Instance Attribute Details
#tag_names ⇒ Object (readonly)
Returns the value of attribute tag_names.
39 40 41 |
# File 'lib/cucumber/ast/tags.rb', line 39 def tag_names @tag_names end |
Class Method Details
.exclude_tag?(tag_name) ⇒ Boolean
20 21 22 |
# File 'lib/cucumber/ast/tags.rb', line 20 def exclude_tag?(tag_name) tag_name =~ EXCLUDE_PATTERN end |
.matches?(source_tag_names, tag_names) ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/cucumber/ast/tags.rb', line 13 def matches?(source_tag_names, tag_names) exclude_tag_names, include_tag_names = tag_names.partition{|tag_name| exclude_tag?(tag_name)} exclude_tag_names.map!{|name| name[1..-1]} check_at_sign_prefix(exclude_tag_names + include_tag_names) !excluded?(source_tag_names, exclude_tag_names) && included?(source_tag_names, include_tag_names) end |
Instance Method Details
#accept(visitor) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/cucumber/ast/tags.rb', line 45 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
52 53 54 |
# File 'lib/cucumber/ast/tags.rb', line 52 def accept_hook?(hook) self.class.matches?(@tag_names, hook.tag_names) end |
#count(tag) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/cucumber/ast/tags.rb', line 56 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
66 67 68 |
# File 'lib/cucumber/ast/tags.rb', line 66 def to_sexp @tag_names.map{|tag_name| [:tag, tag_name]} end |