Sha256: 54de288e09608b7c89a4efbc414f5e12afd9624114065ac798f7a8f179062700

Contents?: true

Size: 978 Bytes

Versions: 29

Compression:

Stored size: 978 Bytes

Contents

require 'cucumber/formatter/io'
require 'cucumber/formatter/pretty'

module Cucumber
  module Formatter
    # The formatter used for <tt>--format tag_cloud</tt>
    # Custom formatter that prints a tag cloud as a table.
    class TagCloud
      include Io

      def initialize(step_mother, path_or_io, options)
        @io = ensure_io(path_or_io, "tag_cloud")
        @options = options
        @counts = Hash.new{|h,k| h[k] = 0}
      end

      def after_features(features)
        print_summary(features)
      end

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

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
cucumber-0.8.7 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.8.5 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.8.4 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.8.3 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.8.2 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.8.1 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.8.0 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.3 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.2 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.1 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.8 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.7 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.6 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.5 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.4 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.3 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.2 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.7.0.beta.1 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.6.4 lib/cucumber/formatter/tag_cloud.rb