class Cucumber::Ast::Tags
:nodoc:
This gets stored internally as ["invoice", "release_2"]
@invoice @release_2
Holds the names of tags parsed from a feature file:
def accept(visitor)
def accept(visitor) return if $cucumber_interrupted @tag_names.each do |tag_name| visitor.visit_tag_name(tag_name) end end
def accept_hook?(hook)
def accept_hook?(hook) self.class.matches?(@tag_names, hook.tag_names) end
def check_at_sign_prefix(tag_names)
def check_at_sign_prefix(tag_names) tag_names.each{|tag_name| raise "Tag names must start with an @ sign. The following tag name didn't: #{tag_name}" unless tag_name[0..0] == '@'} end
def check_if_tags_match(source_tag_names, tag_names)
def check_if_tags_match(source_tag_names, tag_names) tag_exp = Or.new(tag_names.map{|tag_name_list| And.new(tag_name_list) }) tag_exp.matches?(source_tag_names) end
def count(tag)
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
def exclude_tag?(tag_name)
def exclude_tag?(tag_name) tag_name =~ EXCLUDE_PATTERN end
def initialize(line, tag_names)
def initialize(line, tag_names) @line, @tag_names = line, tag_names end
def matches?(source_tag_names, tag_names)
def matches?(source_tag_names, tag_names) validate_tags(tag_names) tag_names.empty? ? true : check_if_tags_match(source_tag_names, tag_names) end
def strip_negative_char(tag_names)
def strip_negative_char(tag_names) tag_names.map{|name| name[1..-1]} end
def to_sexp
def to_sexp @tag_names.map{|tag_name| [:tag, tag_name]} end
def validate_tags(tag_name_list)
def validate_tags(tag_name_list) all_tag_names = tag_name_list.flatten exclude_tag_names, include_tag_names = all_tag_names.partition{|tag_name| exclude_tag?(tag_name)} exclude_tag_names = strip_negative_char(exclude_tag_names) check_at_sign_prefix(exclude_tag_names + include_tag_names) end