crowdin-cli 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/bin/crowdin-cli CHANGED
@@ -143,10 +143,14 @@ command :upload do |c|
143
143
 
144
144
  c.desc 'Upload source files'
145
145
  c.command :sources do |c|
146
+
147
+ c.desc 'defines whether to add sources if there is the same file previously added'
148
+ c.switch [:ignore_duplicates]
149
+
146
150
  c.action do |global_options, options, args|
147
151
  project_info = @crowdin.project_info
148
152
 
149
- source_language = project_info['source_language']['code']
153
+ source_language = project_info['details']['source_language']['code']
150
154
 
151
155
  # Crowdin supported languages list
152
156
  supported_languages = @crowdin.supported_languages
@@ -177,6 +181,8 @@ command :upload do |c|
177
181
  end
178
182
  end
179
183
 
184
+ exit_now!("Nothing to upload") if local_files.empty?
185
+
180
186
  common_dir = find_common_directory_path(dest_files)
181
187
 
182
188
  local_project_tree = get_local_files_hierarchy(local_files.collect{ |h| h[:dest].sub(common_dir, '') })
@@ -191,14 +197,16 @@ command :upload do |c|
191
197
  @crowdin.add_directory(dir)
192
198
  end
193
199
 
194
- # Update existing files in Crowdin project
195
- #
196
- # array containing elements common to the two arrays
197
- update_files = local_project_tree[:files] & remote_project_tree[:files]
198
- files_for_upload = local_files.select{ |file| update_files.include?(file[:dest]) }
199
- files_for_upload.each do |file|
200
- puts "Update file `#{file[:dest]}`"
201
- @crowdin.update_file([] << file)
200
+ unless options[:ignore_duplicates]
201
+ # Update existing files in Crowdin project
202
+ #
203
+ # array containing elements common to the two arrays
204
+ update_files = local_project_tree[:files] & remote_project_tree[:files]
205
+ files_for_upload = local_files.select{ |file| update_files.include?(file[:dest]) }
206
+ files_for_upload.each do |file|
207
+ puts "Update file `#{file[:dest]}`"
208
+ @crowdin.update_file([] << file)
209
+ end
202
210
  end
203
211
 
204
212
  # Add new files to Crowdin project
@@ -247,7 +255,7 @@ command :upload do |c|
247
255
  supported_languages = @crowdin.supported_languages
248
256
  translation_languages = supported_languages.select{ |lang| project_languages.include?(lang['crowdin_code']) }
249
257
 
250
- source_language = project_info['source_language']['code']
258
+ source_language = project_info['details']['source_language']['code']
251
259
  source_language = supported_languages.find{ |lang| lang['crowdin_code'] == source_language }
252
260
 
253
261
  translated_files = Hash.new{ |hash, key| hash[key] = Array.new }
@@ -281,6 +289,8 @@ command :upload do |c|
281
289
  end # if
282
290
  end # @config['files']
283
291
 
292
+ exit_now!("Nothing to upload") if dest_files.empty?
293
+
284
294
  params = {}
285
295
  params[:import_duplicates] = options[:import_dublicates] ? 1 : 0
286
296
  params[:import_eq_suggestions] = options[:import_eq_suggestions] ? 1 : 0
@@ -1,5 +1,5 @@
1
1
  module Crowdin
2
2
  module CLI
3
- VERSION = '0.0.11'
3
+ VERSION = '0.0.12'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
12
+ date: 2012-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake