web_translate_it 2.8.2 → 2.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/history.md +4 -0
- data/lib/web_translate_it/connection.rb +21 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1667be9e5fab89fe2ab18228ab94666225ebd108a6c234bed49c2df9fe5ae31
|
4
|
+
data.tar.gz: 6163b2dc6e981cde12a4a64d2e28f9220d9e2983818dc70d922d60c56993f1f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24a36fbb86cca9fb0abfb2f9c7936a3ef023975ab714080a561966d340b4e9b6f7d27850cf9dacd1bc23ede523d16a8133781f0901e3a325c2ca51f891b943b8
|
7
|
+
data.tar.gz: 191cc4fa792d0026d30a1366f85ecf7ad047dbdcba17e16ed83b4e6c68651883c420fc4870f20e189505b26c253cc94cc524233054cd8865b0435d66c041c97a
|
data/history.md
CHANGED
@@ -2,11 +2,9 @@ module WebTranslateIt
|
|
2
2
|
|
3
3
|
class Connection
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
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/
|
27
|
-
|
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
|
30
|
+
http.set_debug_output($stderr) if @@debug
|
33
31
|
begin
|
34
32
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
35
|
-
|
36
|
-
yield
|
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.'
|
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
|
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
|
-
|
45
|
-
yield
|
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
|
-
|
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
|
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.
|
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-04-
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|