code-ruby 1.8.13 → 1.8.15

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: 3a198577db25eecafeebb990128a74e33af1a52a3eb6e403c90f8f365129a2a5
4
- data.tar.gz: 7ed8ae578905e87c60aecec4e8266018771a03adcb0f673be10ae5a96a132bed
3
+ metadata.gz: 1f71684c4dc7d49cba70fd38bcd64ad838a0f3c303dbb492364e2cd7a8d66d55
4
+ data.tar.gz: 1debf69960b9da25c30f2523aa64df84e7ee0d6fc5b4965d7ceb956c66244a3f
5
5
  SHA512:
6
- metadata.gz: a8c17804e2268dbf8fbbf312762e3e92f9d723533a1b0f7ae382659be3932f5154d89a388388799d17e95d8c1298d2631900178bca0028d074dee9d0ccecaba6
7
- data.tar.gz: 6fb62ac0e048e1a29da2115d1a3b4c3646a4320e6e751847bdeccb8542e075c1205a18e9b51c2256d56ff777ade53564a9dbdc24badd2f2676ff923daa1f1743
6
+ metadata.gz: 7dfb5cc19d6334ca14906b74be16ce26d6bec269e6f78030ad3ce6ef00fa0ded8ade6b6af3c6fb0c0e39aa8849cc64425fec6ee95e669ab8f50cd9d5dd866066
7
+ data.tar.gz: abe4ea08744984d2f84f099dedb81e31b041b3d19a97fa173655f727cdda435d78a790bd5b8601f068ed3c953a7c28ebc7624a2a3ca573de1456ab113af36927
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (1.8.13)
4
+ code-ruby (1.8.15)
5
5
  activesupport
6
6
  base64
7
7
  bigdecimal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.13
1
+ 1.8.15
@@ -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
 
@@ -80,6 +84,7 @@ class Code
80
84
  not_extended: 510,
81
85
  network_authentication_required: 511
82
86
  }.freeze
87
+ DEFAULT_TIMEOUT = 1.hour.to_f
83
88
 
84
89
  def self.call(**args)
85
90
  code_operator = args.fetch(:operator, nil).to_code
@@ -160,6 +165,10 @@ class Code
160
165
  body = options.code_get("body").to_s
161
166
  headers = options.code_get("headers").raw || {}
162
167
  data = options.code_get("data").raw || {}
168
+ timeout = options.code_get("timeout")
169
+ open_timeout = options.code_get("open_timeout")
170
+ read_timeout = options.code_get("read_timeout")
171
+ write_timeout = options.code_get("write_timeout")
163
172
  query = options.code_get("query").raw || {}
164
173
  query = query.to_a.flatten.map(&:to_s).each_slice(2).to_h.to_query
165
174
 
@@ -174,6 +183,16 @@ class Code
174
183
  uri = ::URI.parse(url)
175
184
  http = ::Net::HTTP.new(uri.host, uri.port)
176
185
  http.use_ssl = true if uri.scheme == "https"
186
+ default_timeout = timeout.nothing? ? DEFAULT_TIMEOUT : timeout.to_f
187
+ open_timeout_value = open_timeout.nothing? ? default_timeout : open_timeout.to_f
188
+ read_timeout_value = read_timeout.nothing? ? default_timeout : read_timeout.to_f
189
+ write_timeout_value = write_timeout.nothing? ? default_timeout : write_timeout.to_f
190
+
191
+ http.open_timeout = open_timeout_value if open_timeout_value
192
+ http.read_timeout = read_timeout_value if read_timeout_value
193
+ if http.respond_to?(:write_timeout=) && write_timeout_value
194
+ http.write_timeout = write_timeout_value
195
+ end
177
196
 
178
197
  request_class =
179
198
  case verb
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.13
4
+ version: 1.8.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié