web_translate_it 2.4.7 → 2.4.8

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
  SHA1:
3
- metadata.gz: 37656492f7a6e8dc4217d6f84799a141f9bc30c2
4
- data.tar.gz: 9590f016fa7a25b0453435b06e379566331ae315
3
+ metadata.gz: 9deef6447dcb281c15e92dedce6223314e18b8c1
4
+ data.tar.gz: 60e47ba7afe0ad87462c9ac28f8b2b83ae5caa38
5
5
  SHA512:
6
- metadata.gz: e9a52a91a082f0ef0906319993b13926e47df20997cfc1aa9775032c4a3d21a2f95d1f784c660b2b3fcbf97448b4e24b2c32ab9b6af3a1794c1070e2a298b9d7
7
- data.tar.gz: adcd82f7ce617746a63b6c3dbf838a890c76cbb300b6a205b6a96188a4fca96671d147f49c92f564680ae0ceb74c3e55099a1724fdcd31b2d12f761305e510ba
6
+ metadata.gz: 1094a19a6d0f19cdf4a19335e2f4034724d81338bae26f837acf2780dc9be539f446d40e3e0f8c72c7faef75d83530d9256963f5de841f8077ed67bd8606b43d
7
+ data.tar.gz: 709988816f70f68dcc94aa3c9e2075aecd8e2a43577da4e9ce16be3911c9ea35ef2743c3b6f9af4b344d0ac080b4c972d6036ee8b2f1e14ccaa86d745fdc7784
data/bin/wti CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  $PROGRAM_NAME = 'wti'
4
4
 
5
- require 'trollop'
5
+ require 'optimist'
6
6
  require 'web_translate_it'
7
7
 
8
8
  show_commands = <<-EOS
@@ -18,14 +18,15 @@ The most commonly used wti commands are:
18
18
  rmlocale Delete a locale from a project
19
19
  status Fetch and display project statistics
20
20
  init Configure your project to sync
21
+ configuser Configure your user email
21
22
 
22
23
  See `wti <command> --help` for more information on a specific command.
23
24
 
24
25
  [options] are:
25
26
  EOS
26
27
 
27
- SUB_COMMANDS = %w(pull push match add addlocale status st init)
28
- global_options = Trollop::options do
28
+ SUB_COMMANDS = %w(pull push match add addlocale status st init configuser)
29
+ global_options = Optimist::options do
29
30
  stop_on SUB_COMMANDS
30
31
  banner show_commands
31
32
  version "wti version #{WebTranslateIt::Util.version}"
@@ -34,7 +35,7 @@ end
34
35
  command = ARGV.shift # get the subcommand
35
36
  command_options = case command
36
37
  when "pull"
37
- Trollop::options do
38
+ Optimist::options do
38
39
  banner <<-EOS
39
40
  wti pull [filename] - Pull target language file(s)
40
41
  [options] are:
@@ -46,7 +47,7 @@ EOS
46
47
  opt :debug, "Display debug information"
47
48
  end
48
49
  when "push"
49
- Trollop::options do
50
+ Optimist::options do
50
51
  banner <<-EOS
51
52
  wti push [filename] - Push master language file(s)
52
53
  [options] are:
@@ -64,44 +65,49 @@ EOS
64
65
  opt :debug, "Display debug information"
65
66
  end
66
67
  when "add"
67
- Trollop::options do
68
+ Optimist::options do
68
69
  banner "wti add filename - Create and push a new master language file"
69
70
  opt :low_priority, "WTI will process this file with a low priority"
70
71
  opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
71
72
  opt :debug, "Display debug information"
72
73
  end
73
74
  when "rm"
74
- Trollop::options do
75
+ Optimist::options do
75
76
  banner "wti rm filename - Delete a master language file"
76
77
  opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
77
78
  opt :debug, "Display debug information"
78
79
  end
79
80
  when "addlocale"
80
- Trollop::options do
81
+ Optimist::options do
81
82
  banner "wti addlocale localename - Add a new locale to the project"
82
83
  opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
83
84
  opt :debug, "Display debug information"
84
85
  end
85
86
  when "rmlocale"
86
- Trollop::options do
87
+ Optimist::options do
87
88
  banner "wti rmlocale localename Delete a locale from the project"
88
89
  opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
89
90
  opt :debug, "Display debug information"
90
91
  end
91
92
  when "status"
92
- Trollop::options do
93
+ Optimist::options do
93
94
  banner "wti status - Fetch and display project statistics"
94
95
  opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
95
96
  opt :debug, "Display debug information"
96
97
  end
97
98
  when "init"
98
- Trollop::options do
99
+ Optimist::options do
99
100
  banner "wti init [api_token] - Configure your project to sync"
100
101
  opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
101
102
  opt :debug, "Display debug information"
102
103
  end
104
+ when "configuser"
105
+ Optimist::options do
106
+ banner "wti configuser - Configure your user email"
107
+ opt :debug, "Display debug information"
108
+ end
103
109
  when "match"
104
- Trollop::options do
110
+ Optimist::options do
105
111
  banner "wti match - Display matching of local files with File Manager"
106
112
  opt :config, "Path to a configuration file", :short => "-c", :default => ".wti"
107
113
  opt :debug, "Display debug information"
data/history.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Version 2.4.8 / 2018-09-06
2
+
3
+ * Update deprecated gem `Trollop` to `Optimist`.
4
+
1
5
  ## Version 2.4.7 / 2018-03-28
2
6
 
3
7
  * Add an option to .wti file to silence SSL errors.
@@ -74,4 +74,3 @@ module WebTranslateIt
74
74
  end
75
75
  end
76
76
  end
77
-
@@ -8,8 +8,7 @@ module WebTranslateIt
8
8
  begin
9
9
  WebTranslateIt::Connection.new(api_key) do |http|
10
10
  request = Net::HTTP::Get.new("/api/projects/#{api_key}.yaml")
11
- request.add_field("X-Client-Name", "web_translate_it")
12
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
11
+ WebTranslateIt::Util.add_fields(request)
13
12
  response = http.request(request)
14
13
  if response.is_a?(Net::HTTPSuccess)
15
14
  return response.body
@@ -39,8 +38,7 @@ module WebTranslateIt
39
38
  begin
40
39
  WebTranslateIt::Connection.new(api_key) do |http|
41
40
  request = Net::HTTP::Get.new("/api/projects/#{api_key}/stats.yaml")
42
- request.add_field("X-Client-Name", "web_translate_it")
43
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
41
+ WebTranslateIt::Util.add_fields(request)
44
42
  return Util.handle_response(http.request(request), true)
45
43
  end
46
44
  rescue Timeout::Error
@@ -60,8 +58,7 @@ module WebTranslateIt
60
58
  tries ||= 3
61
59
  begin
62
60
  request = Net::HTTP::Post.new("/api/projects/#{Connection.api_key}/locales")
63
- request.add_field("X-Client-Name", "web_translate_it")
64
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
61
+ WebTranslateIt::Util.add_fields(request)
65
62
  request.set_form_data({ 'id' => locale_code }, ';')
66
63
  Util.handle_response(Connection.http_connection.request(request), true)
67
64
  rescue Timeout::Error
@@ -81,8 +78,7 @@ module WebTranslateIt
81
78
  tries ||= 3
82
79
  begin
83
80
  request = Net::HTTP::Delete.new("/api/projects/#{Connection.api_key}/locales/#{locale_code}")
84
- request.add_field("X-Client-Name", "web_translate_it")
85
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
81
+ WebTranslateIt::Util.add_fields(request)
86
82
  Util.handle_response(Connection.http_connection.request(request), true)
87
83
  rescue Timeout::Error
88
84
  puts "Request timeout. Will retry in 5 seconds."
@@ -58,9 +58,7 @@ module WebTranslateIt
58
58
  url += '?' + HashUtil.to_params("filters" => params) unless params.empty?
59
59
 
60
60
  request = Net::HTTP::Get.new(url)
61
- request.add_field("X-Client-Name", "web_translate_it")
62
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
63
-
61
+ WebTranslateIt::Util.add_fields(request)
64
62
  begin
65
63
  strings = []
66
64
  while(request) do
@@ -73,8 +71,7 @@ module WebTranslateIt
73
71
  if response["Link"] && response["Link"].include?("rel=\"next\"")
74
72
  url = response["Link"].match(/<(.*)>; rel="next"/)[1]
75
73
  request = Net::HTTP::Get.new(url)
76
- request.add_field("X-Client-Name", "web_translate_it")
77
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
74
+ WebTranslateIt::Util.add_fields(request)
78
75
  else
79
76
  request = nil
80
77
  end
@@ -110,9 +107,7 @@ module WebTranslateIt
110
107
  success = true
111
108
  tries ||= 3
112
109
  request = Net::HTTP::Get.new("/api/projects/#{Connection.api_key}/strings/#{id}.yaml")
113
- request.add_field("X-Client-Name", "web_translate_it")
114
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
115
-
110
+ WebTranslateIt::Util.add_fields(request)
116
111
  begin
117
112
  response = Connection.http_connection.request(request)
118
113
  return nil if response.code.to_i == 404
@@ -160,9 +155,7 @@ module WebTranslateIt
160
155
  success = true
161
156
  tries ||= 3
162
157
  request = Net::HTTP::Delete.new("/api/projects/#{Connection.api_key}/strings/#{self.id}")
163
- request.add_field("X-Client-Name", "web_translate_it")
164
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
165
-
158
+ WebTranslateIt::Util.add_fields(request)
166
159
  begin
167
160
  Util.handle_response(Connection.http_connection.request(request), true, true)
168
161
  rescue Timeout::Error
@@ -194,9 +187,7 @@ module WebTranslateIt
194
187
  return translation if translation
195
188
  return nil if self.new_record
196
189
  request = Net::HTTP::Get.new("/api/projects/#{Connection.api_key}/strings/#{self.id}/locales/#{locale}/translations.yaml")
197
- request.add_field("X-Client-Name", "web_translate_it")
198
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
199
-
190
+ WebTranslateIt::Util.add_fields(request)
200
191
  begin
201
192
  response = Util.handle_response(Connection.http_connection.request(request), true, true)
202
193
  hash = YAML.load(response)
@@ -225,9 +216,7 @@ module WebTranslateIt
225
216
  success = true
226
217
  tries ||= 3
227
218
  request = Net::HTTP::Put.new("/api/projects/#{Connection.api_key}/strings/#{self.id}.yaml")
228
- request.add_field("X-Client-Name", "web_translate_it")
229
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
230
- request.add_field("Content-Type", "application/json")
219
+ WebTranslateIt::Util.add_fields(request)
231
220
  request.body = self.to_json
232
221
 
233
222
  self.translations.each do |translation|
@@ -256,11 +245,8 @@ module WebTranslateIt
256
245
  success = true
257
246
  tries ||= 3
258
247
  request = Net::HTTP::Post.new("/api/projects/#{Connection.api_key}/strings")
259
- request.add_field("X-Client-Name", "web_translate_it")
260
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
261
- request.add_field("Content-Type", "application/json")
248
+ WebTranslateIt::Util.add_fields(request)
262
249
  request.body = self.to_json(true)
263
-
264
250
  begin
265
251
  response = YAML.load(Util.handle_response(Connection.http_connection.request(request), true, true))
266
252
  self.id = response["id"]
@@ -49,9 +49,7 @@ module WebTranslateIt
49
49
  url += '?' + HashUtil.to_params(params) unless params.empty?
50
50
 
51
51
  request = Net::HTTP::Get.new(url)
52
- request.add_field("X-Client-Name", "web_translate_it")
53
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
54
-
52
+ WebTranslateIt::Util.add_fields(request)
55
53
  begin
56
54
  terms = []
57
55
  while(request) do
@@ -64,8 +62,7 @@ module WebTranslateIt
64
62
  if response["Link"] && response["Link"].include?("rel=\"next\"")
65
63
  url = response["Link"].match(/<(.*)>; rel="next"/)[1]
66
64
  request = Net::HTTP::Get.new(url)
67
- request.add_field("X-Client-Name", "web_translate_it")
68
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
65
+ WebTranslateIt::Util.add_fields(request)
69
66
  else
70
67
  request = nil
71
68
  end
@@ -101,9 +98,7 @@ module WebTranslateIt
101
98
  success = true
102
99
  tries ||= 3
103
100
  request = Net::HTTP::Get.new("/api/projects/#{Connection.api_key}/terms/#{term_id}.yaml")
104
- request.add_field("X-Client-Name", "web_translate_it")
105
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
106
-
101
+ WebTranslateIt::Util.add_fields(request)
107
102
  begin
108
103
  response = Connection.http_connection.request(request)
109
104
  return nil if response.code.to_i == 404
@@ -151,9 +146,7 @@ module WebTranslateIt
151
146
  success = true
152
147
  tries ||= 3
153
148
  request = Net::HTTP::Delete.new("/api/projects/#{Connection.api_key}/terms/#{self.id}")
154
- request.add_field("X-Client-Name", "web_translate_it")
155
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
156
-
149
+ WebTranslateIt::Util.add_fields(request)
157
150
  begin
158
151
  Util.handle_response(Connection.http_connection.request(request), true, true)
159
152
  rescue Timeout::Error
@@ -185,9 +178,7 @@ module WebTranslateIt
185
178
  return translation if translation
186
179
  return nil if self.new_record
187
180
  request = Net::HTTP::Get.new("/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml")
188
- request.add_field("X-Client-Name", "web_translate_it")
189
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
190
-
181
+ WebTranslateIt::Util.add_fields(request)
191
182
  begin
192
183
  response = Util.handle_response(Connection.http_connection.request(request), true, true)
193
184
  array = YAML.load(response)
@@ -217,10 +208,7 @@ module WebTranslateIt
217
208
  success = true
218
209
  tries ||= 3
219
210
  request = Net::HTTP::Put.new("/api/projects/#{Connection.api_key}/terms/#{self.id}.yaml")
220
- request.add_field("X-Client-Name", "web_translate_it")
221
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
222
- request.add_field("Content-Type", "application/json")
223
-
211
+ WebTranslateIt::Util.add_fields(request)
224
212
  request.body = self.to_json
225
213
 
226
214
  self.translations.each do |translation|
@@ -246,10 +234,7 @@ module WebTranslateIt
246
234
  success = true
247
235
  tries ||= 3
248
236
  request = Net::HTTP::Post.new("/api/projects/#{Connection.api_key}/terms")
249
- request.add_field("X-Client-Name", "web_translate_it")
250
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
251
- request.add_field("Content-Type", "application/json")
252
-
237
+ WebTranslateIt::Util.add_fields(request)
253
238
  request.body = self.to_json(true)
254
239
 
255
240
  begin
@@ -60,10 +60,7 @@ module WebTranslateIt
60
60
  success = true
61
61
  tries ||= 3
62
62
  request = Net::HTTP::Post.new("/api/projects/#{Connection.api_key}/terms/#{self.term_id}/locales/#{self.locale}/translations")
63
- request.add_field("X-Client-Name", "web_translate_it")
64
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
65
- request.add_field("Content-Type", "application/json")
66
-
63
+ WebTranslateIt::Util.add_fields(request)
67
64
  request.body = self.to_json
68
65
 
69
66
  begin
@@ -88,12 +85,8 @@ module WebTranslateIt
88
85
  success = true
89
86
  tries ||= 3
90
87
  request = Net::HTTP::Put.new("/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{self.locale}/translations/#{self.id}")
91
- request.add_field("X-Client-Name", "web_translate_it")
92
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
93
- request.add_field("Content-Type", "application/json")
94
-
88
+ WebTranslateIt::Util.add_fields(request)
95
89
  request.body = self.to_json
96
-
97
90
  begin
98
91
  Util.handle_response(Connection.http_connection.request(request), true, true)
99
92
  rescue Timeout::Error
@@ -44,11 +44,8 @@ module WebTranslateIt
44
44
  def save
45
45
  tries ||= 3
46
46
  request = Net::HTTP::Post.new("/api/projects/#{Connection.api_key}/strings/#{self.string_id}/locales/#{self.locale}/translations")
47
- request.add_field("X-Client-Name", "web_translate_it")
48
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
49
- request.add_field("Content-Type", "application/json")
47
+ WebTranslateIt::Util.add_fields(request)
50
48
  request.body = self.to_json
51
-
52
49
  begin
53
50
  Util.handle_response(Connection.http_connection.request(request), true, true)
54
51
  rescue Timeout::Error
@@ -45,8 +45,7 @@ module WebTranslateIt
45
45
  if !File.exist?(self.file_path) or force or self.remote_checksum != self.local_checksum
46
46
  begin
47
47
  request = Net::HTTP::Get.new(api_url)
48
- request.add_field("X-Client-Name", "web_translate_it")
49
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
48
+ WebTranslateIt::Util.add_fields(request)
50
49
  FileUtils.mkpath(self.file_path.split('/')[0..-2].join('/')) unless File.exist?(self.file_path) or self.file_path.split('/')[0..-2].join('/') == ""
51
50
  begin
52
51
  response = http_connection.request(request)
@@ -94,8 +93,7 @@ module WebTranslateIt
94
93
  File.open(self.file_path) do |file|
95
94
  begin
96
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 })
97
- request.add_field("X-Client-Name", "web_translate_it")
98
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
96
+ WebTranslateIt::Util.add_fields(request)
99
97
  display.push Util.handle_response(http_connection.request(request))
100
98
  rescue Timeout::Error
101
99
  puts StringUtil.failure("Request timeout. Will retry in 5 seconds.")
@@ -141,8 +139,7 @@ module WebTranslateIt
141
139
  File.open(self.file_path) do |file|
142
140
  begin
143
141
  request = Net::HTTP::Post::Multipart.new(api_url_for_create, { "name" => self.file_path, "file" => UploadIO.new(file, "text/plain", file.path), "low_priority" => low_priority })
144
- request.add_field("X-Client-Name", "web_translate_it")
145
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
142
+ WebTranslateIt::Util.add_fields(request)
146
143
  display.push Util.handle_response(http_connection.request(request))
147
144
  puts ArrayUtil.to_columns(display)
148
145
  rescue Timeout::Error
@@ -175,8 +172,7 @@ module WebTranslateIt
175
172
  File.open(self.file_path) do |file|
176
173
  begin
177
174
  request = Net::HTTP::Delete.new(api_url_for_delete)
178
- request.add_field("X-Client-Name", "web_translate_it")
179
- request.add_field("X-Client-Version", WebTranslateIt::Util.version)
175
+ WebTranslateIt::Util.add_fields(request)
180
176
  display.push Util.handle_response(http_connection.request(request))
181
177
  puts ArrayUtil.to_columns(display)
182
178
  rescue Timeout::Error
@@ -40,6 +40,12 @@ module WebTranslateIt
40
40
  end
41
41
  end
42
42
 
43
+ def self.add_fields(request)
44
+ request.add_field("X-Client-Name", "web_translate_it")
45
+ request.add_field("X-Client-Version", version)
46
+ request.add_field("Content-Type", "application/json")
47
+ end
48
+
43
49
  ##
44
50
  # Ask a question. Returns a true for yes, false for no, default for nil.
45
51
 
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.7
4
+ version: 2.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Briere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2018-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: trollop
28
+ name: optimist
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: multi_json
43
43
  requirement: !ruby/object:Gem::Requirement