shoptet 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shoptet.rb +1 -1
- data/lib/shoptet/request.rb +18 -4
- 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: 39d32c0913a994e39a4886c159bedeb2c8d18a62e2c02d6d1934e49d5cbc4702
|
4
|
+
data.tar.gz: fc99b75ec8e3c0224dfd67d5783c447deb6b3de890558166c7ed1a41b50ed017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 134155a8e5d780c772344f94a4cd1a1d82273bc714128b9a95b43ea83b816122e748cc59d4237d62e247af83dcdbf4ecb96b0a56620e60f931e58290dc58d35f
|
7
|
+
data.tar.gz: 169ed27569a934a8a5b19a042f0054412cc0c950c3a6f92a7048874eb2864bbb3b3fa5e33543d3412f8e4d798024fd4a26265facd332ad5d246317832ba252ef
|
data/lib/shoptet.rb
CHANGED
data/lib/shoptet/request.rb
CHANGED
@@ -16,7 +16,7 @@ class Shoptet
|
|
16
16
|
request[key] = value
|
17
17
|
end
|
18
18
|
|
19
|
-
response = http.request(request)
|
19
|
+
response = handle_net_timeouts { http.request(request) }
|
20
20
|
parsed_body = Oj.load(response.body, mode: :compat)
|
21
21
|
|
22
22
|
unless parsed_body
|
@@ -25,8 +25,6 @@ class Shoptet
|
|
25
25
|
end
|
26
26
|
|
27
27
|
parsed_body
|
28
|
-
rescue Net::OpenTimeout => e
|
29
|
-
raise(e.class, "#{e.message} - on url #{url}")
|
30
28
|
end
|
31
29
|
|
32
30
|
def self.post url, body
|
@@ -34,10 +32,26 @@ class Shoptet
|
|
34
32
|
request.set_form_data(body)
|
35
33
|
|
36
34
|
response = Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
|
37
|
-
http.request(request)
|
35
|
+
handle_net_timeouts { http.request(request) }
|
38
36
|
end
|
39
37
|
|
40
38
|
Oj.load(response.body, mode: :compat)
|
41
39
|
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def self.handle_net_timeouts
|
44
|
+
attempts = 0
|
45
|
+
|
46
|
+
begin
|
47
|
+
yield
|
48
|
+
rescue Net::OpenTimeout
|
49
|
+
raise if retries > 3
|
50
|
+
|
51
|
+
retries += 1
|
52
|
+
|
53
|
+
retry
|
54
|
+
end
|
55
|
+
end
|
42
56
|
end
|
43
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoptet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Premysl Donat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|