Class: SpecI18n::CommandLine::Language
- Inherits:
-
Object
- Object
- SpecI18n::CommandLine::Language
- Extended by:
- Parser
- Defined in:
- lib/spec-i18n/command_line/language_help_formatter.rb
Class Method Summary collapse
- .hooks_table(io, language) ⇒ Object
- .keywords_table(io, language) ⇒ Object
- .list_keywords_and_exit(io, lang) ⇒ Object
-
.list_languages_and_exit(io) ⇒ Object
List Name and Native Keywords of all the languages in the languages.yml.
- .matchers_table(io, language) ⇒ Object
-
.print_table(io, raw, options = {}) ⇒ Object
Print the table to list all languages or keywords of a language.
-
.table_for_languages(languages) ⇒ Object
Return a table to use with command to list all languages.
Class Method Details
.hooks_table(io, language) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/spec-i18n/command_line/language_help_formatter.rb', line 77 def hooks_table(io, language) hooks = language.hooks_permutation return nil if hooks.empty? table_for_hooks = table do self.headings = ['Rspec Hooks', 'Translated Keyword'] hooks.each do |rspec_keyword, translated_keyword| add_row [rspec_keyword, translated_keyword.join(' / ')] end end print_table io, table_for_hooks true end |
.keywords_table(io, language) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/spec-i18n/command_line/language_help_formatter.rb', line 53 def keywords_table(io, language) table_for_keywords = table do self.headings = ['Rspec Keywords', 'Translated Keyword'] language.basic_keywords.sort.each do |rspec_keyword, translated_keyword| add_row [rspec_keyword, translated_keyword.to_s.split('|').join(' / ')] end end print_table io, table_for_keywords end |
.list_keywords_and_exit(io, lang) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/spec-i18n/command_line/language_help_formatter.rb', line 38 def list_keywords_and_exit(io, lang) language = NaturalLanguage.new(lang) keywords_table(io, language) matchers_table(io, language) hooks_table(io, language) Kernel.exit(0) end |
.list_languages_and_exit(io) ⇒ Object
List Name and Native Keywords of all the languages in the languages.yml
24 25 26 27 |
# File 'lib/spec-i18n/command_line/language_help_formatter.rb', line 24 def list_languages_and_exit(io) languages = list_languages print_table io, table_for_languages(languages), :exit => true end |
.matchers_table(io, language) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/spec-i18n/command_line/language_help_formatter.rb', line 63 def matchers_table(io, language) matchers = language.matchers return if matchers.empty? table_for_matchers = table do self.headings = ['Rspec Matchers', 'Translated Keyword'] matchers.sort.each do |rspec_keyword, translated_keyword| keyword = translated_keyword ? translated_keyword.split('|').join(' / ') : '' add_row [rspec_keyword, keyword] end end print_table io, table_for_matchers true end |
.print_table(io, raw, options = {}) ⇒ Object
Print the table to list all languages or keywords of a language
48 49 50 51 |
# File 'lib/spec-i18n/command_line/language_help_formatter.rb', line 48 def print_table(io, raw, ={}) io.puts raw Kernel.exit(0) if [:exit] end |
.table_for_languages(languages) ⇒ Object
Return a table to use with command to list all languages
31 32 33 34 35 36 |
# File 'lib/spec-i18n/command_line/language_help_formatter.rb', line 31 def table_for_languages(languages) table do self.headings = ['Language', 'Name', 'Native'] languages.each { |language| add_row language } end end |