Module: I18n::Tasks::Command::Commands::Data
- Includes:
- I18n::Tasks::Command::Collection
- Included in:
- I18n::Tasks::Commands
- Defined in:
- lib/i18n/tasks/command/commands/data.rb
Instance Method Summary collapse
- #check_normalized(opt) ⇒ Object
- #cp(opt = {}) ⇒ Object
- #data(opt = {}) ⇒ Object
- #data_merge(opt = {}) ⇒ Object
- #data_remove(opt = {}) ⇒ Object
- #data_write(opt = {}) ⇒ Object
- #mv(opt = {}) ⇒ Object
- #normalize(opt = {}) ⇒ Object
- #rm(opt = {}) ⇒ Object
Methods included from I18n::Tasks::Command::Collection
Instance Method Details
#check_normalized(opt) ⇒ Object
29 30 31 32 33 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 29 def check_normalized(opt) non_normalized = i18n.non_normalized_paths locales: opt[:locales] terminal_report.check_normalized_results(non_normalized) :exit1 unless non_normalized.empty? end |
#cp(opt = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 52 def cp(opt = {}) fail CommandError, 'requires FROM_KEY_PATTERN and TO_KEY_PATTERN' if opt[:arguments].size < 2 from_pattern = opt[:arguments].shift to_pattern = opt[:arguments].shift forest = i18n.data_forest results = forest.mv_key!(compile_key_pattern(from_pattern), to_pattern, root: false, retain: true) i18n.data.write forest terminal_report.cp_results results end |
#data(opt = {}) ⇒ Object
82 83 84 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 82 def data(opt = {}) print_forest i18n.data_forest(opt[:locales]), opt end |
#data_merge(opt = {}) ⇒ Object
91 92 93 94 95 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 91 def data_merge(opt = {}) forest = merge_forests_stdin_and_pos!(opt) merged = i18n.data.merge!(forest) print_forest merged, opt end |
#data_remove(opt = {}) ⇒ Object
113 114 115 116 117 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 113 def data_remove(opt = {}) removed = i18n.data.remove_by_key!(forest_pos_or_stdin!(opt)) log_stderr 'Removed:' print_forest removed, opt end |
#data_write(opt = {}) ⇒ Object
102 103 104 105 106 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 102 def data_write(opt = {}) forest = forest_pos_or_stdin!(opt) i18n.data.write forest print_forest forest, opt end |
#mv(opt = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 38 def mv(opt = {}) fail CommandError, 'requires FROM_KEY_PATTERN and TO_KEY_PATTERN' if opt[:arguments].size < 2 from_pattern = opt[:arguments].shift to_pattern = opt[:arguments].shift forest = i18n.data_forest results = forest.mv_key!(compile_key_pattern(from_pattern), to_pattern, root: false) i18n.data.write forest terminal_report.mv_results results end |
#normalize(opt = {}) ⇒ Object
19 20 21 22 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 19 def normalize(opt = {}) i18n.normalize_store! locales: opt[:locales], force_pattern_router: opt[:pattern_router] end |
#rm(opt = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/i18n/tasks/command/commands/data.rb', line 66 def rm(opt = {}) fail CommandError, 'requires KEY_PATTERN' if opt[:arguments].empty? forest = i18n.data_forest results = opt[:arguments].each_with_object({}) do |key_pattern, h| h.merge! forest.mv_key!(compile_key_pattern(key_pattern), '', root: false) end i18n.data.write forest terminal_report.mv_results results end |