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

Attributes inherited from Ast::Visitor

#options, #step_mother

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Formatter::Pretty

#initialize, #visit_background, #visit_background_name, #visit_comment, #visit_comment_line, #visit_examples_name, #visit_exception, #visit_feature, #visit_feature_element, #visit_feature_element_name, #visit_feature_name, #visit_features, #visit_py_string, #visit_scenario_name, #visit_step, #visit_step_name, #visit_step_result, #visit_tag_name, #visit_tags

Methods included from Formatter::Console

#announce, #format_step, #format_string, #print_counts, #print_elements, #print_exception, #print_snippets, #print_steps

Methods included from Formatter::ANSIColor

#grey

Methods inherited from Ast::Visitor

#announce, #initialize, #matches_scenario_names?, #visit_background, #visit_background_name, #visit_comment, #visit_comment_line, #visit_examples, #visit_examples_name, #visit_exception, #visit_feature, #visit_feature_element, #visit_feature_name, #visit_features, #visit_outline_table, #visit_py_string, #visit_scenario_name, #visit_step, #visit_step_name, #visit_step_result, #visit_steps, #visit_table_cell, #visit_tag_name, #visit_tags

Constructor Details

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

Class Method Details

.list_keywords(io, lang) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/cucumber/cli/language_help_formatter.rb', line 24

def self.list_keywords(io, 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?(lang)}, '').visit_multiline_arg(table)
end

.list_languages(io) ⇒ Object



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

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)
end

Instance Method Details

#visit_multiline_arg(table) ⇒ Object



32
33
34
35
36
37
# File 'lib/cucumber/cli/language_help_formatter.rb', line 32

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

#visit_table_cell_value(value, width, status) ⇒ Object



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

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 = :undefined
  end
  
  @col += 1
  super(value, width, status)
end

#visit_table_row(table_row) ⇒ Object



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

def visit_table_row(table_row)
  @col = 1
  super
end