Sha256: b8e20f811622b40e1c0b9cad67fa46b2a475f5db191427999f0c06f71e00b96d

Contents?: true

Size: 974 Bytes

Versions: 9

Compression:

Stored size: 974 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

9 entries across 9 versions & 2 rubygems

Version Path
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/cucumber-0.9.4/lib/cucumber/formatter/tag_cloud.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/cucumber-0.9.4/lib/cucumber/formatter/tag_cloud.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/cucumber-0.9.4/lib/cucumber/formatter/tag_cloud.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/cucumber-0.9.4/lib/cucumber/formatter/tag_cloud.rb
cucumber-0.9.4 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.9.3 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.9.2 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.9.1 lib/cucumber/formatter/tag_cloud.rb
cucumber-0.9.0 lib/cucumber/formatter/tag_cloud.rb