Sha256: 27bdf7c76e224e95b51a3168b776ff940fa2493be0b5e62e200126d843e0f5a2

Contents?: true

Size: 1.12 KB

Versions: 386

Compression:

Stored size: 1.12 KB

Contents

module Gherkin
  module Formatter
    class TagCountFormatter
      def initialize(formatter, tag_counts)
        @formatter = formatter
        @tag_counts = tag_counts
      end

      def uri(uri)
        @uri = uri
      end

      def feature(feature)
        @feature_tags = feature.tags
        @formatter.feature(feature)
      end

      def scenario(scenario)
        record_tags((@feature_tags.to_a + scenario.tags.to_a).uniq, scenario.line)
        @formatter.scenario(scenario)
      end

      def scenario_outline(scenario_outline)
        @scenario_outline_tags = scenario_outline.tags
        @formatter.scenario_outline(scenario_outline)
      end

      def examples(examples)
        record_tags((@feature_tags.to_a + @scenario_outline_tags.to_a + examples.tags.to_a).uniq, examples.line)
        @formatter.examples(examples)
      end

    private

      def record_tags(tags, line)
        tags.each do |tag|
          @tag_counts[tag.name] ||= []
          @tag_counts[tag.name] << "#{@uri}:#{line}"
        end
      end

      def method_missing(*args)
        @formatter.__send__(*args)
      end
    end
  end
end

Version data entries

386 entries across 379 versions & 11 rubygems

Version Path
gherkin-2.11.8-x86-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.8-x86-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.8-java lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.7 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.7-x86-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.7-x86-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.7-java lib/gherkin/formatter/tag_count_formatter.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/gherkin-2.11.6/lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.6 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.6-x86-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.6-x86-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.6-java lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.5 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.5-x86-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.5-x86-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.5-java lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.4 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.4-x86-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.4-x86-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.11.4-java lib/gherkin/formatter/tag_count_formatter.rb