Sha256: b66f1f496f60f60228b0cba22afadd6efc4c5eb26a3bc9d9fd3e68d542331566

Contents?: true

Size: 1002 Bytes

Versions: 2

Compression:

Stored size: 1002 Bytes

Contents

module Cucumber
  module Ast
    # Holds the names of tags parsed from a feature file:
    #
    #   @invoice @release_2
    #
    # This gets stored internally as <tt>["invoice", "release_2"]</tt>
    #
    class Tags
      def initialize(line, tag_names)
        @line, @tag_names = line, tag_names
      end

      def among?(tag_names)
        no_tags, yes_tags = tag_names.partition{|tag| tag =~ /^\!/}
        no_tags = no_tags.map{|tag| tag[1..-1]}

        # Strip @
        yes_tags = yes_tags.map{|tag| tag =~ /^@(.*)/ ? $1 : tag}
        no_tags = no_tags.map{|tag| tag =~ /^@(.*)/ ? $1 : tag}

        (@tag_names & yes_tags).any? && (@tag_names & no_tags).empty?
      end

      def at_lines?(lines)
        lines.empty? || lines.index(@line)
      end

      def accept(visitor)
        @tag_names.each do |tag_name|
          visitor.visit_tag_name(tag_name)
        end
      end
      
      def to_sexp
        @tag_names.map{|tag_name| [:tag, tag_name]}
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
aslakhellesoy-cucumber-0.1.99.21 lib/cucumber/ast/tags.rb
kosmas58-cucumber-0.1.99.21 lib/cucumber/ast/tags.rb