Sha256: 0c90677a9b165fec0e171a98c02d4014beba5364dd57bc1ffc53d74b2a2e70bb

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 KB

Contents

require 'cucumber/formatter/pretty'

module Cucumber
  module Cli2
    class LanguageHelpFormatter < Formatter::Pretty
      INCOMPLETE = %{
This language is incomplete. Please translate the missing words in
#{Cucumber::LANGUAGE_FILE}

Then contribute back to the Cucumber project. Details here:
http://wiki.github.com/aslakhellesoy/cucumber/spoken-languages
}

      def self.list_languages(io)
        raw = Cucumber::LANGUAGES.keys.sort.map do |lang|
          [lang, Cucumber::LANGUAGES[lang]['name'], Cucumber::LANGUAGES[lang]['native']]
        end
        table = Ast::Table.new(raw)
        new(nil, io, {:check_lang=>true}, '').visit_multiline_arg(table, :passed)
      end

      def self.list_keywords(io, lang)
        Cucumber.load_language(lang)
        raw = Cucumber::KEYWORD_KEYS.map do |key|
          [key, Cucumber::LANGUAGES[lang][key]]
        end
        table = Ast::Table.new(raw)
        new(nil, io, {:incomplete => Cucumber.language_incomplete?}, '').visit_multiline_arg(table, :passed)
      end

      def visit_multiline_arg(table, status)
        if @options[:incomplete]
          @io.puts(format_string(INCOMPLETE, :failed))
        end
        super
      end

      def visit_table_row(table_row, status)
        @col = 1
        super
      end

      def visit_table_cell_value(value, width, status)
        if @col == 1
          if(@options[:check_lang])
            @incomplete = Cucumber.language_incomplete?(value)
          end
          status = :comment 
        elsif @incomplete
          status = :failed
        end
        
        @col += 1
        super(value, width, status)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aslakhellesoy-cucumber-0.1.99.11 lib/cucumber/cli/language_help_formatter.rb
aslakhellesoy-cucumber-0.1.99.12 lib/cucumber/cli/language_help_formatter.rb
aslakhellesoy-cucumber-0.1.99.13 lib/cucumber/cli/language_help_formatter.rb
aslakhellesoy-cucumber-0.1.99.14 lib/cucumber/cli/language_help_formatter.rb
aslakhellesoy-cucumber-0.1.99.15 lib/cucumber/cli/language_help_formatter.rb