Class: Cucumber::Cli::LanguageHelpFormatter

Inherits:
Formatter::Pretty show all
Defined in:
lib/cucumber/cli/language_help_formatter.rb

Constant Summary collapse

INCOMPLETE =
%{
The Cucumber grammar has evolved since this translation was written.
Please help us complete the translation by translating the missing words in

#{Cucumber::LANGUAGE_FILE}

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

Constants included from Formatter::Console

Formatter::Console::FORMATS

Constants included from Formatter::ANSIColor

Formatter::ANSIColor::ALIASES

Instance Attribute Summary

Attributes inherited from Formatter::Pretty

#indent, #step_mother

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Formatter::Pretty

#after_background, #after_feature, #after_feature_element, #after_features, #after_multiline_arg, #after_outline_table, #after_table_cell, #after_table_row, #after_tags, #background_name, #before_background, #before_examples_array, #before_feature, #before_feature_element, #before_multiline_arg, #before_outline_table, #before_step, #before_step_result, #before_table_row, #comment_line, #examples_name, #exception, #feature_name, #initialize, #py_string, #scenario_name, #step_name, #table_cell_value, #tag_name

Methods included from Formatter::Console

#announce, #format_step, #format_string, #print_counts, #print_elements, #print_exception, #print_passing_wip, #print_snippets, #print_stats, #print_steps, #print_tag_limit_warnings, #record_tag_occurrences

Methods included from Formatter::ANSIColor

define_grey, define_real_grey, #grey

Methods included from Formatter::Duration

#format_duration

Constructor Details

This class inherits a constructor from Cucumber::Formatter::Pretty

Class Method Details

.list_keywords(io, lang) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/cucumber/cli/language_help_formatter.rb', line 26

def self.list_keywords(io, lang)
  language = Parser::NaturalLanguage.get(nil, lang)
  raw = Parser::NaturalLanguage::KEYWORD_KEYS.map do |key|
    [key, language.keywords(key)]
  end
  table = Ast::Table.new(raw)
  new(nil, io, {:incomplete => language.incomplete?}).visit_multiline_arg(table)
end

.list_languages(io) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/cucumber/cli/language_help_formatter.rb', line 17

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)
  formatter = new(nil, io, {:check_lang=>true})
  Ast::TreeWalker.new(nil, [formatter]).visit_multiline_arg(table)
end

Instance Method Details

#before_visit_multiline_arg(table) ⇒ Object



35
36
37
38
39
# File 'lib/cucumber/cli/language_help_formatter.rb', line 35

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

#before_visit_table_cell_value(value, status) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cucumber/cli/language_help_formatter.rb', line 45

def before_visit_table_cell_value(value, status)
  if @col == 1
    if(@options[:check_lang])
      @incomplete = Parser::NaturalLanguage.get(nil, value).incomplete?
    end
    status = :comment 
  elsif @incomplete
    status = :undefined
  end
  
  @col += 1
end

#before_visit_table_row(table_row) ⇒ Object



41
42
43
# File 'lib/cucumber/cli/language_help_formatter.rb', line 41

def before_visit_table_row(table_row)
  @col = 1
end