moonrope-client 1.0.4 → 1.0.5
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 +4 -4
- data/lib/moonrope_client/connection.rb +15 -5
- data/lib/moonrope_client/error.rb +12 -0
- data/lib/moonrope_client/version.rb +1 -1
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e354b83a2648af524ba82261be24f4eade87122b4bd042c2b13d81638105d505
|
4
|
+
data.tar.gz: 0a2fef71abb2c870938b97ce60e241fb39ef1b66990be7889a938afd0059c39d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77438b37bc152c59ecdb5a7e4325aa33688ee2f28383fc65c538d51c798e98a00c9b8013041d5a6536f89814c49945461d0fa9e101b1c1551e61703fae509474
|
7
|
+
data.tar.gz: 5e793e6c03c223f0bec41ea11c212edf1fe7b2d938fc392a4c3c80a9cfb293b87391353b4294f775819e8a04bc1b8dabf22924798c0d8c2cbf40fb6b4c3ea694
|
@@ -96,6 +96,7 @@ module MoonropeClient
|
|
96
96
|
request.add_field 'User-Agent', self.user_agent
|
97
97
|
headers.each { |k,v| request.add_field k, v }
|
98
98
|
connection = Net::HTTP.new(self.host, self.port)
|
99
|
+
connection.open_timeout = @options[:connect_timeout] || 10
|
99
100
|
if ssl
|
100
101
|
connection.use_ssl = true
|
101
102
|
connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
@@ -103,12 +104,21 @@ module MoonropeClient
|
|
103
104
|
result = connection.request(request)
|
104
105
|
case result.code.to_i
|
105
106
|
when 200 then result.body
|
106
|
-
when 400
|
107
|
-
|
108
|
-
when
|
109
|
-
|
110
|
-
|
107
|
+
when 400
|
108
|
+
raise Error.new("Bad request (400)", body: result.body)
|
109
|
+
when 403
|
110
|
+
raise Error.new("Access denied (403)", body: result.body)
|
111
|
+
when 404
|
112
|
+
raise Error.new("Page not found (404)", body: result.body)
|
113
|
+
when 301..309
|
114
|
+
raise Error.new("Redirect (#{result.code})", body: result.body, location: result['Location'])
|
115
|
+
when 500
|
116
|
+
raise Error.new("Internal server error (500)", body: result.body)
|
117
|
+
else
|
118
|
+
raise Error.new("Error (#{result.code.to_i})", body: result.body)
|
111
119
|
end
|
120
|
+
rescue Net::OpenTimeout
|
121
|
+
raise Error.new("Connection timeout to #{self.host}:#{self.port}")
|
112
122
|
end
|
113
123
|
|
114
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moonrope-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "~>"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '1.8'
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "~>"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '1.8'
|
26
|
+
version: '0'
|
33
27
|
description: A full client library allows requests to made to Moonrope-enabled API
|
34
28
|
endpoints.
|
35
29
|
email:
|
@@ -70,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
64
|
- !ruby/object:Gem::Version
|
71
65
|
version: '0'
|
72
66
|
requirements: []
|
73
|
-
rubygems_version: 3.0.
|
67
|
+
rubygems_version: 3.0.3
|
74
68
|
signing_key:
|
75
69
|
specification_version: 4
|
76
70
|
summary: A client library for the the Moonrope API server.
|