Method: WebTranslateIt::CommandLine#add
- Defined in:
- lib/web_translate_it/command_line.rb
#add ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/web_translate_it/command_line.rb', line 153 def add # rubocop:todo Metrics/AbcSize, Metrics/MethodLength complete_success = true $stdout.sync = true if parameters == [] puts StringUtil.failure('Error: You must provide the path to the master file to add.') puts 'Usage: wti add path/to/master_file_1 path/to/master_file_2 ...' exit end WebTranslateIt::Connection.new(configuration.api_key) do |http| added = configuration.files.find_all { |file| file.locale == configuration.source_locale }.to_set { |file| File.(file.file_path) } to_add = parameters.reject { |param| added.include?(File.(param)) } if to_add.any? to_add.each do |param| file = TranslationFile.new(nil, param.gsub(/ /, '\\ '), nil, configuration.api_key) success = file.create(http) complete_success = false unless success end else puts 'No new master file to add.' end end complete_success end |