Sha256: de3c0e4426edb527afc786ed4380531126ab026914f25b693caa0a085bd842b9

Contents?: true

Size: 705 Bytes

Versions: 5

Compression:

Stored size: 705 Bytes

Contents

module Cucumber
  module Formatter
    # Custom formatter that prints a tag cloud
    class TagCloud < Cucumber::Ast::Visitor
      def initialize(step_mother, io, options)
        super(step_mother)
        @io = io
        @counts = Hash.new{|h,k| h[k] = 0}
      end

      def visit_features(features)
        super
        print_summary
      end

      def visit_tag_name(tag_name)
        @counts[tag_name] += 1
      end
  
      def print_summary
        matrix = @counts.to_a.sort{|paira, pairb| paira[0] <=> pairb[0]}.transpose
        table = Cucumber::Ast::Table.new(matrix)
        Cucumber::Formatter::Pretty.new(@step_mother, @io, {}).visit_multiline_arg(table)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
aslakhellesoy-cucumber-0.3.6.1 lib/cucumber/formatter/tag_cloud.rb
aslakhellesoy-cucumber-0.3.7.1 lib/cucumber/formatter/tag_cloud.rb
aslakhellesoy-cucumber-0.3.7 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.3.6 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.3.7 lib/cucumber/formatter/tag_cloud.rb