web_translate_it 2.8.1 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0e54082c0439b780e3660717222784124f206b4852e8fb86b620dbf5f30d838
4
- data.tar.gz: 020f7410586d5c2b00719764fa363ca9b41855732f4c167835115fbaa5265141
3
+ metadata.gz: a1667be9e5fab89fe2ab18228ab94666225ebd108a6c234bed49c2df9fe5ae31
4
+ data.tar.gz: 6163b2dc6e981cde12a4a64d2e28f9220d9e2983818dc70d922d60c56993f1f0
5
5
  SHA512:
6
- metadata.gz: 35e1c48c7f05b38fe31dbb4c0c530379ed06e37926a82e117a89bc6a5721c9bcd38f4a22f3f550ec67cafa62a493c7ebe7398a7c9c3c801cdc57bccd63b94260
7
- data.tar.gz: 3f86840ec5d6fac566e341bbe2a0722d30950d0112dae8a903ad9e9c54ab35d34f7cdf409d8a1f8b966791cb1955465942573995e960b959314e04d766f46019
6
+ metadata.gz: 24a36fbb86cca9fb0abfb2f9c7936a3ef023975ab714080a561966d340b4e9b6f7d27850cf9dacd1bc23ede523d16a8133781f0901e3a325c2ca51f891b943b8
7
+ data.tar.gz: 191cc4fa792d0026d30a1366f85ecf7ad047dbdcba17e16ed83b4e6c68651883c420fc4870f20e189505b26c253cc94cc524233054cd8865b0435d66c041c97a
data/history.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## Version 2.8.3 / 2023-04-19
2
+
3
+ * Fix `wti addlocale` and `wti rmlocale` commands. #253
4
+
5
+ ## Version 2.8.2 / 2023-04-18
6
+
7
+ * Fix crash caused by use of API from older Multipart versions. #246 (@rogerluan)
8
+ * Relax dependency to `multipart_post` to `>=0`.
9
+
1
10
  ## Version 2.8.1 / 2023-03-13
2
11
 
3
12
  * Replace YAML API calls with JSON API calls. (#242)
@@ -2,11 +2,9 @@ module WebTranslateIt
2
2
 
3
3
  class Connection
4
4
 
5
- attr_reader :api_key, :http_connection
6
-
7
- @api_key = nil
8
- @http_connection = nil
9
- @debug = false
5
+ @@api_key = nil
6
+ @@http_connection = nil
7
+ @@debug = false
10
8
 
11
9
  #
12
10
  # Initialize and yield a HTTPS Keep-Alive connection to WebTranslateIt.com
@@ -23,33 +21,41 @@ module WebTranslateIt
23
21
  # http_connection.request(request)
24
22
  # end
25
23
  #
26
- def initialize(api_key) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
27
- @api_key = api_key
24
+ def initialize(api_key) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
25
+ @@api_key = api_key
28
26
  proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : Struct.new(:host, :port, :user, :password).new
29
27
  http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new('webtranslateit.com', 443)
30
28
  http.use_ssl = true
31
29
  http.open_timeout = http.read_timeout = 60
32
- http.set_debug_output($stderr) if @debug
30
+ http.set_debug_output($stderr) if @@debug
33
31
  begin
34
32
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
35
- @http_connection = http.start
36
- yield @http_connection if block_given?
33
+ @@http_connection = http.start
34
+ yield @@http_connection if block_given?
37
35
  rescue OpenSSL::SSL::SSLError
38
- puts 'Unable to verify SSL certificate.' unless @silent
36
+ puts 'Unable to verify SSL certificate.'
39
37
  http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new('webtranslateit.com', 443)
40
- http.set_debug_output($stderr) if @debug
38
+ http.set_debug_output($stderr) if @@debug
41
39
  http.use_ssl = true
42
40
  http.open_timeout = http.read_timeout = 60
43
41
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
44
- @http_connection = http.start
45
- yield @http_connection if block_given?
42
+ @@http_connection = http.start
43
+ yield @@http_connection if block_given?
46
44
  rescue StandardError
47
45
  puts $ERROR_INFO
48
46
  end
49
47
  end
50
48
 
51
49
  def self.turn_debug_on
52
- @debug = true
50
+ @@debug = true
51
+ end
52
+
53
+ def self.api_key
54
+ @@api_key
55
+ end
56
+
57
+ def self.http_connection
58
+ @@http_connection
53
59
  end
54
60
 
55
61
  end
@@ -96,7 +96,7 @@ module WebTranslateIt
96
96
  if File.exist?(file_path)
97
97
  if force || (remote_checksum != local_checksum)
98
98
  File.open(file_path) do |file|
99
- params = {'file' => ::Multipart::Post::UploadIO.new(file, 'text/plain', file.path), 'merge' => merge, 'ignore_missing' => ignore_missing, 'label' => label, 'minor_changes' => minor_changes}
99
+ params = {'file' => UploadIO.new(file, 'text/plain', file.path), 'merge' => merge, 'ignore_missing' => ignore_missing, 'label' => label, 'minor_changes' => minor_changes}
100
100
  params['name'] = destination_path unless destination_path.nil?
101
101
  params['rename_others'] = rename_others
102
102
  request = Net::HTTP::Put::Multipart.new(api_url, params)
@@ -147,7 +147,7 @@ module WebTranslateIt
147
147
  display.push "#{StringUtil.checksumify(local_checksum.to_s)}..[ ]"
148
148
  if File.exist?(file_path)
149
149
  File.open(file_path) do |file|
150
- request = ::Net::HTTP::Post::Multipart.new(api_url_for_create, {'name' => file_path, 'file' => Multipart::Post::UploadIO.new(file, 'text/plain', file.path)})
150
+ request = Net::HTTP::Post::Multipart.new(api_url_for_create, {'name' => file_path, 'file' => UploadIO.new(file, 'text/plain', file.path)})
151
151
  WebTranslateIt::Util.add_fields(request)
152
152
  display.push Util.handle_response(http_connection.request(request))
153
153
  puts ArrayUtil.to_columns(display)
data/readme.md CHANGED
@@ -272,4 +272,4 @@ fr: 100% translated, 100% completed.
272
272
 
273
273
  # License
274
274
 
275
- Copyright (c) 2009-2022 [WebTranslateIt Software S.L](https://webtranslateit.com), released under the MIT License.
275
+ Copyright (c) 2009-2023 [WebTranslateIt Software S.L](https://webtranslateit.com), 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.8.1
4
+ version: 2.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Briere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-13 00:00:00.000000000 Z
11
+ date: 2023-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: multipart-post
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.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
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.4.6
117
+ rubygems_version: 3.4.10
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: A CLI tool to sync locale files with WebTranslateIt.com.