code-ruby 1.8.12 → 1.8.14
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/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/object/http.rb +19 -1
- data/lib/code/parser/call.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9878b7c9982e4c6a8ce5fe805e7554146806aafbf0ab49cea8506041aa32aa9a
|
|
4
|
+
data.tar.gz: e8903b2ab607f7e07c703d13e4ef7737e6794498dd35ec930f90753089ed6664
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: faab10cb784cd9bdf971cf8ad3db74e200c6367ee52c1116290f15525789d8e9d0186721b4918533352d03b9f8db0a67d63955f5019facc82036dbb100692d87
|
|
7
|
+
data.tar.gz: c3485d1f028729ce3bd227129e165f52e6fa261a18567d69357e4e600f44b600076406b402d81a48c2bf1ee8942220cb111fa687348f7818a408a0a84a7a7a65
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.8.
|
|
1
|
+
1.8.14
|
data/lib/code/object/http.rb
CHANGED
|
@@ -11,7 +11,11 @@ class Code
|
|
|
11
11
|
body: String.maybe,
|
|
12
12
|
username: String.maybe,
|
|
13
13
|
password: String.maybe,
|
|
14
|
-
data: Dictionary.maybe
|
|
14
|
+
data: Dictionary.maybe,
|
|
15
|
+
timeout: (Integer | Decimal).maybe,
|
|
16
|
+
open_timeout: (Integer | Decimal).maybe,
|
|
17
|
+
read_timeout: (Integer | Decimal).maybe,
|
|
18
|
+
write_timeout: (Integer | Decimal).maybe
|
|
15
19
|
}
|
|
16
20
|
].freeze
|
|
17
21
|
|
|
@@ -160,6 +164,10 @@ class Code
|
|
|
160
164
|
body = options.code_get("body").to_s
|
|
161
165
|
headers = options.code_get("headers").raw || {}
|
|
162
166
|
data = options.code_get("data").raw || {}
|
|
167
|
+
timeout = options.code_get("timeout")
|
|
168
|
+
open_timeout = options.code_get("open_timeout")
|
|
169
|
+
read_timeout = options.code_get("read_timeout")
|
|
170
|
+
write_timeout = options.code_get("write_timeout")
|
|
163
171
|
query = options.code_get("query").raw || {}
|
|
164
172
|
query = query.to_a.flatten.map(&:to_s).each_slice(2).to_h.to_query
|
|
165
173
|
|
|
@@ -174,6 +182,16 @@ class Code
|
|
|
174
182
|
uri = ::URI.parse(url)
|
|
175
183
|
http = ::Net::HTTP.new(uri.host, uri.port)
|
|
176
184
|
http.use_ssl = true if uri.scheme == "https"
|
|
185
|
+
default_timeout = timeout.nothing? ? Float::INFINITY : timeout.to_f
|
|
186
|
+
open_timeout_value = open_timeout.nothing? ? default_timeout : open_timeout.to_f
|
|
187
|
+
read_timeout_value = read_timeout.nothing? ? default_timeout : read_timeout.to_f
|
|
188
|
+
write_timeout_value = write_timeout.nothing? ? default_timeout : write_timeout.to_f
|
|
189
|
+
|
|
190
|
+
http.open_timeout = open_timeout_value if open_timeout_value
|
|
191
|
+
http.read_timeout = read_timeout_value if read_timeout_value
|
|
192
|
+
if http.respond_to?(:write_timeout=) && write_timeout_value
|
|
193
|
+
http.write_timeout = write_timeout_value
|
|
194
|
+
end
|
|
177
195
|
|
|
178
196
|
request_class =
|
|
179
197
|
case verb
|
data/lib/code/parser/call.rb
CHANGED
|
@@ -11,6 +11,10 @@ class Code
|
|
|
11
11
|
Whitespace
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def whiltespace_without_newline?
|
|
15
|
+
Whitespace.new.without_newline.maybe
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
def whitespace?
|
|
15
19
|
whitespace.maybe
|
|
16
20
|
end
|
|
@@ -148,7 +152,7 @@ class Code
|
|
|
148
152
|
def root
|
|
149
153
|
(
|
|
150
154
|
name.aka(:name) << (whitespace? << arguments.aka(:arguments)).maybe <<
|
|
151
|
-
(
|
|
155
|
+
(whiltespace_without_newline? << block.aka(:block)).maybe
|
|
152
156
|
).aka(:call)
|
|
153
157
|
end
|
|
154
158
|
end
|