web_translate_it 2.4.9 → 2.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee4e863643d0a26d473d758833bbb905bf5d375de25e0892cae8068d72c5a688
4
- data.tar.gz: 8a3f926cb779cfc79a491d9a0085c1c5dc1a624877a503da3b06f1fe3ad1dd90
3
+ metadata.gz: eb3fcef09897665d610fe38915e9a5f68858357f6e11839be6f34c10286dfb0f
4
+ data.tar.gz: 70cad073ebdac68cceb0d54688a0168f9794d9ca9adeda8520a5cecce68d021d
5
5
  SHA512:
6
- metadata.gz: dc9b48b992ef306e4a4f8955f0fedab83a8f50a8715137cc8e93d0fc7f3552266d15f33a195f6767781c52335f1c8f0d22bf4fc266e1e77feaf810f55647e7c6
7
- data.tar.gz: c2f83a87eb83ff79c4c6753bdcab18bd80aa5db17970b33a065b6267afb2b63e794e7c001a7aabddc883527d219b319392cc2e8e7d36511c35640cc1866e3736
6
+ metadata.gz: 755ac1081486d0937458aa143093f9ba017d5c012bc972cf46d3294110c82240ded1aba0941a5b1fce71285808b56e466c4ef158978e57864011a46eea2209d5
7
+ data.tar.gz: ff08d126ad22c2b3129301e03dd0ecda77a36b6ce54fce572ca15c09b45aac11768c15cab8038377f0c2bc2b332cac8ab965c4d65e6b37fe3692b5d6f9ea10ea
data/bin/wti CHANGED
@@ -14,18 +14,18 @@ The most commonly used wti commands are:
14
14
  match Display matching of local files with File Manager
15
15
  add Create and push a new master language file
16
16
  rm Delete a master language file from a project
17
+ mv Moves a file both locally and from a project
17
18
  addlocale Add a new locale to the project
18
19
  rmlocale Delete a locale from a project
19
20
  status Fetch and display project statistics
20
21
  init Configure your project to sync
21
- configuser Configure your user email
22
22
 
23
23
  See `wti <command> --help` for more information on a specific command.
24
24
 
25
25
  [options] are:
26
26
  EOS
27
27
 
28
- SUB_COMMANDS = %w(pull push match add addlocale status st init configuser)
28
+ SUB_COMMANDS = %w(pull push match add rm mv addlocale rmlocale status st init)
29
29
  global_options = Optimist::options do
30
30
  stop_on SUB_COMMANDS
31
31
  banner show_commands
@@ -40,10 +40,10 @@ command_options = case command
40
40
  wti pull [filename] - Pull target language file(s)
41
41
  [options] are:
42
42
  EOS
43
- opt :locale, "ISO code of locale(s) to pull", :type => :string
43
+ opt :locale, "ISO code of locale(s) to pull", type: :string
44
44
  opt :all, "Pull all files"
45
45
  opt :force, "Force pull (bypass conditional requests to WTI)"
46
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
46
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
47
47
  opt :debug, "Display debug information"
48
48
  end
49
49
  when "push"
@@ -52,15 +52,15 @@ EOS
52
52
  wti push [filename] - Push master language file(s)
53
53
  [options] are:
54
54
  EOS
55
- opt :locale, "ISO code of locale(s) to push", :type => :string
55
+ opt :locale, "ISO code of locale(s) to push", type: :string
56
56
  opt :target, "Upload all target files"
57
57
  opt :force, "Force push (bypass conditional requests to WTI)"
58
58
  opt :low_priority, "WTI will process this file with a low priority"
59
59
  opt :merge, "Force WTI to merge this file"
60
60
  opt :ignore_missing, "Force WTI to not obsolete missing strings"
61
61
  opt :minor, "Minor Changes. When pushing a master file, prevents target translations to be flagged as `to_verify`."
62
- opt :label, "Apply a label to the changes", :type => :string
63
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
62
+ opt :label, "Apply a label to the changes", type: :string
63
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
64
64
  opt :all, "DEPRECATED -- See `wti push --target` instead"
65
65
  opt :debug, "Display debug information"
66
66
  end
@@ -68,48 +68,49 @@ EOS
68
68
  Optimist::options do
69
69
  banner "wti add filename - Create and push a new master language file"
70
70
  opt :low_priority, "WTI will process this file with a low priority"
71
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
71
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
72
72
  opt :debug, "Display debug information"
73
73
  end
74
74
  when "rm"
75
75
  Optimist::options do
76
76
  banner "wti rm filename - Delete a master language file"
77
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
77
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
78
78
  opt :debug, "Display debug information"
79
79
  end
80
+ when "mv"
81
+ Optimist::options do
82
+ banner "wti mv filename - Moves a master language file and its target files"
83
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
84
+ opt :debug, "Display debug information"
85
+ end
80
86
  when "addlocale"
81
87
  Optimist::options do
82
88
  banner "wti addlocale localename - Add a new locale to the project"
83
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
89
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
84
90
  opt :debug, "Display debug information"
85
91
  end
86
92
  when "rmlocale"
87
93
  Optimist::options do
88
94
  banner "wti rmlocale localename Delete a locale from the project"
89
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
95
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
90
96
  opt :debug, "Display debug information"
91
97
  end
92
98
  when "status"
93
99
  Optimist::options do
94
100
  banner "wti status - Fetch and display project statistics"
95
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
101
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
96
102
  opt :debug, "Display debug information"
97
103
  end
98
104
  when "init"
99
105
  Optimist::options do
100
106
  banner "wti init [api_token] - Configure your project to sync"
101
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
102
- opt :debug, "Display debug information"
103
- end
104
- when "configuser"
105
- Optimist::options do
106
- banner "wti configuser - Configure your user email"
107
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
107
108
  opt :debug, "Display debug information"
108
109
  end
109
110
  when "match"
110
111
  Optimist::options do
111
112
  banner "wti match - Display matching of local files with File Manager"
112
- opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
113
+ opt :config, "Path to a configuration file", short: "-c", default: ".wti"
113
114
  opt :debug, "Display debug information"
114
115
  end
115
116
  else
@@ -128,4 +129,3 @@ rescue Interrupt => e
128
129
  puts StringUtil.failure("\nQuitting...")
129
130
  exit 1
130
131
  end
131
-
data/history.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Version 2.4.10 / 2019-10-21
2
+
3
+ * New command: `wti mv path/to/file.po newpath/to/file.po` to move a language file
4
+ both on your local working directory and on your WebTranslateIt project.
5
+ * Fix: `wti pull something` now doesn’t pull anything if no files match what needs to be pulled. Close #151.
6
+
1
7
  ## Version 2.4.9 / 2019-08-07
2
8
 
3
9
  * Fix issue referencing old `Trollop` library. #149
@@ -18,6 +18,8 @@ module WebTranslateIt
18
18
  message = "Creating master files"
19
19
  when 'rm'
20
20
  message = "Deleting files"
21
+ when 'mv'
22
+ message = "Moving files"
21
23
  when 'addlocale'
22
24
  message = "Adding locale"
23
25
  when 'rmlocale'
@@ -44,7 +46,7 @@ module WebTranslateIt
44
46
  parameters.each do |parameter|
45
47
  found_files += files.find_all{ |file| File.fnmatch(parameter, file.file_path) }
46
48
  end
47
- files = found_files if found_files.any?
49
+ files = found_files
48
50
  files = files.uniq.sort{ |a,b| a.file_path <=> b.file_path }
49
51
  if files.size == 0
50
52
  puts "No files to pull."
@@ -127,26 +129,77 @@ module WebTranslateIt
127
129
  STDOUT.sync = true
128
130
  if parameters == []
129
131
  puts StringUtil.failure("Error: You must provide the path to the master file to remove.")
130
- puts "Usage: wti path/to/rm master_file_1 path/to/master_file_2 ..."
132
+ puts "Usage: wti rm path/to/master_file_1 path/to/master_file_2 ..."
131
133
  exit
132
134
  end
133
135
  WebTranslateIt::Connection.new(configuration.api_key) do |http|
134
136
  parameters.each do |param|
135
137
  if Util.ask_yes_no("Are you sure you want to delete the master file #{param}?\nThis will also delete its target files and translations.", false)
136
- configuration.files.find_all{ |file| file.file_path == param }.each do |master_file|
137
- master_file.delete(http)
138
- # delete files
139
- success = File.delete(master_file.file_path) if File.exists?(master_file.file_path)
140
- complete_success = false if !success
141
- configuration.files.find_all{ |file| file.master_id == master_file.id }.each do |target_file|
142
- success = File.delete(target_file.file_path) if File.exists?(target_file.file_path)
138
+ files = configuration.files.find_all{ |file| file.file_path == param }
139
+ if files.any?
140
+ files.each do |master_file|
141
+ master_file.delete(http)
142
+ # delete files
143
+ if File.exists?(master_file.file_path)
144
+ success = File.delete(master_file.file_path)
145
+ puts StringUtil.success("Deleted master file #{master_file.file_path}.") if success
146
+ end
143
147
  complete_success = false if !success
148
+ configuration.files.find_all{ |file| file.master_id == master_file.id }.each do |target_file|
149
+ if File.exists?(target_file.file_path)
150
+ success = File.delete(target_file.file_path)
151
+ puts StringUtil.success("Deleted target file #{target_file.file_path}.") if success
152
+ else
153
+ puts StringUtil.failure("Target file #{target_file.file_path} doesn’t exist locally")
154
+ end
155
+ complete_success = false if !success
156
+ end
144
157
  end
158
+ puts StringUtil.success("All done.") if complete_success
159
+ else
160
+ puts StringUtil.failure("#{param}: File doesn’t exist on project.")
161
+ end
162
+ end
163
+ end
164
+ end
165
+ complete_success
166
+ end
167
+
168
+ def mv
169
+ complete_success = true
170
+ STDOUT.sync = true
171
+ if parameters.count != 2
172
+ puts StringUtil.failure("Error: You must provide the source path and destination path of the master file to move.")
173
+ puts "Usage: wti mv path/to/master_file_old_path path/to/master_file_new_path ..."
174
+ exit
175
+ end
176
+ source = parameters[0]
177
+ destination = parameters[1]
178
+ WebTranslateIt::Connection.new(configuration.api_key) do |http|
179
+ if Util.ask_yes_no("Are you sure you want to move the master file #{source} and its target files?", true)
180
+ configuration.files.find_all{ |file| file.file_path == source }.each do |master_file|
181
+ master_file.upload(http, false, false, nil, false, false, true, true, destination)
182
+ # move master file
183
+ if File.exists?(source)
184
+ success = File.rename(source, destination) if File.exists?(source)
185
+ puts StringUtil.success("Moved master file #{master_file.file_path}.") if success
186
+ end
187
+ complete_success = false if !success
188
+ configuration.files.find_all{ |file| file.master_id == master_file.id }.each do |target_file|
189
+ if File.exists?(target_file.file_path)
190
+ success = File.delete(target_file.file_path)
191
+ complete_success = false if !success
192
+ end
193
+ end
194
+ configuration.reload
195
+ configuration.files.find_all{ |file| file.master_id == master_file.id }.each do |target_file|
196
+ success = target_file.fetch(http)
197
+ complete_success = false if !success
145
198
  end
199
+ puts StringUtil.success("All done.") if complete_success
146
200
  end
147
201
  end
148
202
  end
149
- puts StringUtil.success("Master file deleted.")
150
203
  complete_success
151
204
  end
152
205
 
@@ -33,11 +33,23 @@ module WebTranslateIt
33
33
  WebTranslateIt::Connection.turn_silent_on if configuration['silence_errors']
34
34
  self.project_name = project_info['project']['name']
35
35
  else
36
- puts StringUtil.failure("\nCan't find a configuration file in #{File.expand_path(path_to_config_file, self.path)}")
36
+ puts StringUtil.failure("\nNo configuration file found in #{File.expand_path(path_to_config_file, self.path)}")
37
37
  exit(1)
38
38
  end
39
39
  end
40
40
 
41
+ # Reload project data
42
+ #
43
+ def reload
44
+ project_info = YAML.load WebTranslateIt::Project.fetch_info(self.api_key)
45
+ set_locales_to_ignore(configuration)
46
+ set_locales_needed(configuration)
47
+ set_files(project_info['project'])
48
+ set_locales(project_info['project'])
49
+ WebTranslateIt::Connection.turn_silent_on if configuration['silence_errors']
50
+ self.project_name = project_info['project']['name']
51
+ end
52
+
41
53
  # Set the project locales from the Project API.
42
54
  # Implementation example:
43
55
  #
@@ -82,7 +82,7 @@ module WebTranslateIt
82
82
  #
83
83
  # Note that the request might or might not eventually be acted upon, as it might be disallowed when processing
84
84
  # actually takes place. This is due to the fact that language file imports are handled by background processing.
85
- def upload(http_connection, merge=false, ignore_missing=false, label=nil, low_priority=false, minor_changes=false, force=false)
85
+ def upload(http_connection, merge=false, ignore_missing=false, label=nil, low_priority=false, minor_changes=false, force=false, rename_others=false, destination_path=nil)
86
86
  success = true
87
87
  tries ||= 3
88
88
  display = []
@@ -92,7 +92,10 @@ module WebTranslateIt
92
92
  if force or self.remote_checksum != self.local_checksum
93
93
  File.open(self.file_path) do |file|
94
94
  begin
95
- request = Net::HTTP::Put::Multipart.new(api_url, {"file" => UploadIO.new(file, "text/plain", file.path), "merge" => merge, "ignore_missing" => ignore_missing, "label" => label, "low_priority" => low_priority, "minor_changes" => minor_changes })
95
+ params = {"file" => UploadIO.new(file, "text/plain", file.path), "merge" => merge, "ignore_missing" => ignore_missing, "label" => label, "low_priority" => low_priority, "minor_changes" => minor_changes }
96
+ params["name"] = destination_path unless destination_path.nil?
97
+ params["rename_others"] = rename_others
98
+ request = Net::HTTP::Put::Multipart.new(api_url, params)
96
99
  WebTranslateIt::Util.add_fields(request)
97
100
  display.push Util.handle_response(http_connection.request(request))
98
101
  rescue Timeout::Error
@@ -113,7 +116,7 @@ module WebTranslateIt
113
116
  end
114
117
  puts ArrayUtil.to_columns(display)
115
118
  else
116
- puts StringUtil.failure("Can't push #{self.file_path}. File doesn't exist.")
119
+ puts StringUtil.failure("Can't push #{self.file_path}. File doesn't exist locally.")
117
120
  end
118
121
  return success
119
122
  end
@@ -156,7 +159,7 @@ module WebTranslateIt
156
159
  end
157
160
  end
158
161
  else
159
- puts StringUtil.failure("\nFile #{self.file_path} doesn't exist!")
162
+ puts StringUtil.failure("\nFile #{self.file_path} doesn't exist locally!")
160
163
  end
161
164
  return success
162
165
  end
@@ -169,27 +172,25 @@ module WebTranslateIt
169
172
  display = []
170
173
  display.push file_path
171
174
  if File.exists?(self.file_path)
172
- File.open(self.file_path) do |file|
173
- begin
174
- request = Net::HTTP::Delete.new(api_url_for_delete)
175
- WebTranslateIt::Util.add_fields(request)
176
- display.push Util.handle_response(http_connection.request(request))
177
- puts ArrayUtil.to_columns(display)
178
- rescue Timeout::Error
179
- puts StringUtil.failure("Request timeout. Will retry in 5 seconds.")
180
- if (tries -= 1) > 0
181
- sleep(5)
182
- retry
183
- else
184
- success = false
185
- end
186
- rescue
187
- display.push StringUtil.failure("An error occured: #{$!}")
175
+ begin
176
+ request = Net::HTTP::Delete.new(api_url_for_delete)
177
+ WebTranslateIt::Util.add_fields(request)
178
+ display.push Util.handle_response(http_connection.request(request))
179
+ puts ArrayUtil.to_columns(display)
180
+ rescue Timeout::Error
181
+ puts StringUtil.failure("Request timeout. Will retry in 5 seconds.")
182
+ if (tries -= 1) > 0
183
+ sleep(5)
184
+ retry
185
+ else
188
186
  success = false
189
187
  end
188
+ rescue
189
+ display.push StringUtil.failure("An error occured: #{$!}")
190
+ success = false
190
191
  end
191
192
  else
192
- puts StringUtil.failure("\nFile #{self.file_path} doesn't exist!")
193
+ puts StringUtil.failure("\nMaster file #{self.file_path} doesn't exist locally!")
193
194
  end
194
195
  return success
195
196
  end
data/license CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2009-2014 Atelier Convivialite
3
+ Copyright (c) 2009-2019 WebTranslateIt Software S.L
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/readme.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  wti lets you easily sync your language files with [WebTranslateIt.com](https://webtranslateit.com), a web-based tool to translation software.
9
9
 
10
- <img src="https://s3.amazonaws.com/f.cl.ly/items/27192V1K263K2O433h2g/webtranslateit_com_%E2%80%94_edouard_Edouards-MacBook-Pro-2____code_webtranslateit_com_%E2%80%94___anslateit_com_%E2%80%94_zsh_%E2%80%94_80%C3%9740.png" alt="WebTranslateIt Synchronization Tool" width="500px">
10
+ <img src="http://edouard.baconfile.com.s3.us-east-1.amazonaws.com/web_translate_it/wti4.png" alt="WebTranslateIt Synchronization Tool" width="500px">
11
11
 
12
12
  ### wti...
13
13
 
@@ -276,4 +276,4 @@ fr: 100% translated, 100% completed.
276
276
 
277
277
  # License
278
278
 
279
- Copyright (c) 2009-2018 Atelier Convivialité, released under the MIT License.
279
+ Copyright (c) 2009-2019 WebTranslateIt Software S.L, released under the MIT License.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_translate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.9
4
+ version: 2.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Briere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2019-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post