nxt_http_client 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 906874f8a8f0e5ae19c90126d8913901a7cdb27f8c4c83addb0cd8b4f8a27375
4
- data.tar.gz: a0799e986d3c67d29d4d6219392c415526725df5d2a7912e3cb82546ed3aaa6d
3
+ metadata.gz: 5245a6f9449699cdffdac8c33cc39dab56cbcd3f492144595729bf6533c9e852
4
+ data.tar.gz: 6c09b7f3ef57eb1df6234516f7da6a9917924a43b89280efbeea791e0d9c1cef
5
5
  SHA512:
6
- metadata.gz: 2500e2589bdbfb113f4bf060e0391f7ecbc2d559ad461c4f3b4f97aae25d9f2f897e972e995f7c4b91c5ec1980299ee58c99c41864a1f55c832caf4899e6a4a8
7
- data.tar.gz: 506c9ddd7b17195debe34456e0e8f475e6be235b1f9de8615197f3e3417eb76b784929a1373b982de67e0d62fc75adeac8a3932f262d2af472e59be4a90f1bdb
6
+ metadata.gz: c86f043555c8e493c3be467da02ab7fcb4935cc48a1b2e637c7ae6c424de3c6b02327baed9d50e329ae8b509b699b02dfb868f4f7f24bcbc9056fb4a610e576b
7
+ data.tar.gz: 5077dd7b17869a9803d8ebd7cc1e4b14546ea45b682588ca0b16e2612e52f3ac4933353f2fc30e811e21c8ca418a2c370bc397f9c71aab5918143fd904cc8c3c
@@ -1,21 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nxt_http_client (0.2.7)
4
+ nxt_http_client (0.2.8)
5
5
  activesupport (~> 6.0.0)
6
+ nxt_registry
6
7
  typhoeus
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- activesupport (6.0.0)
12
+ activesupport (6.0.2.1)
12
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
14
  i18n (>= 0.7, < 2)
14
15
  minitest (~> 5.1)
15
16
  tzinfo (~> 1.1)
16
- zeitwerk (~> 2.1, >= 2.1.8)
17
- addressable (2.6.0)
18
- public_suffix (>= 2.0.2, < 4.0)
17
+ zeitwerk (~> 2.2)
18
+ addressable (2.7.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
19
20
  coderay (1.1.2)
20
21
  concurrent-ruby (1.1.5)
21
22
  crack (0.4.3)
@@ -23,46 +24,48 @@ GEM
23
24
  diff-lcs (1.3)
24
25
  ethon (0.12.0)
25
26
  ffi (>= 1.3.0)
26
- ffi (1.11.1)
27
+ ffi (1.11.3)
27
28
  hashdiff (1.0.0)
28
- i18n (1.6.0)
29
+ i18n (1.8.1)
29
30
  concurrent-ruby (~> 1.0)
30
31
  method_source (0.9.2)
31
- minitest (5.11.3)
32
+ minitest (5.13.0)
33
+ nxt_registry (0.1.3)
34
+ activesupport
32
35
  nxt_vcr_harness (0.1.3)
33
36
  rspec (~> 3.0)
34
37
  vcr (~> 5.0)
35
38
  pry (0.12.2)
36
39
  coderay (~> 1.1.0)
37
40
  method_source (~> 0.9.0)
38
- public_suffix (3.1.1)
41
+ public_suffix (4.0.1)
39
42
  rake (10.5.0)
40
- redis (4.1.2)
41
- rspec (3.8.0)
42
- rspec-core (~> 3.8.0)
43
- rspec-expectations (~> 3.8.0)
44
- rspec-mocks (~> 3.8.0)
45
- rspec-core (3.8.2)
46
- rspec-support (~> 3.8.0)
47
- rspec-expectations (3.8.4)
43
+ redis (4.1.3)
44
+ rspec (3.9.0)
45
+ rspec-core (~> 3.9.0)
46
+ rspec-expectations (~> 3.9.0)
47
+ rspec-mocks (~> 3.9.0)
48
+ rspec-core (3.9.0)
49
+ rspec-support (~> 3.9.0)
50
+ rspec-expectations (3.9.0)
48
51
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-mocks (3.8.1)
52
+ rspec-support (~> 3.9.0)
53
+ rspec-mocks (3.9.0)
51
54
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-support (3.8.2)
55
+ rspec-support (~> 3.9.0)
56
+ rspec-support (3.9.0)
54
57
  safe_yaml (1.0.5)
55
58
  thread_safe (0.3.6)
56
59
  typhoeus (1.3.1)
57
60
  ethon (>= 0.9.0)
58
- tzinfo (1.2.5)
61
+ tzinfo (1.2.6)
59
62
  thread_safe (~> 0.1)
60
63
  vcr (5.0.0)
61
- webmock (3.6.0)
64
+ webmock (3.7.6)
62
65
  addressable (>= 2.3.6)
63
66
  crack (>= 0.3.2)
64
67
  hashdiff (>= 0.4.0, < 2.0.0)
65
- zeitwerk (2.1.9)
68
+ zeitwerk (2.2.2)
66
69
 
67
70
  PLATFORMS
68
71
  ruby
@@ -79,4 +82,4 @@ DEPENDENCIES
79
82
  webmock
80
83
 
81
84
  BUNDLED WITH
82
- 1.17.2
85
+ 1.17.3
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # NxtHttpClient
2
2
 
3
- Build http clients with ease. NxtHttpClient is a simple DSL on top of the typhoeus gem.
4
- The idea is that you can configure a client on the class level and then adjust or further configure
5
- request options on an instance level. All http interactions are handled by typhoeus. If you need to
3
+ Build http clients with ease. NxtHttpClient is a simple DSL on top of the awesome typhoeus gem.
4
+ The idea is that you can configure your http clients on the class level and then adjust or further configure
5
+ request options on the instance level. All http interactions are handled by typhoeus. If you need to
6
6
  access the original `Typhoeus::Request` in your instance, you can do that.
7
7
 
8
8
  ## Installation
@@ -1,5 +1,6 @@
1
1
  require 'active_support/all'
2
2
  require 'typhoeus'
3
+ require 'nxt_registry'
3
4
 
4
5
  require 'nxt_http_client/version'
5
6
  require 'nxt_http_client/response_handler'
@@ -1,9 +1,15 @@
1
1
  module NxtHttpClient
2
2
  class ResponseHandler
3
3
  CallbackAlreadyRegistered = Class.new(StandardError)
4
+ include NxtRegistry
4
5
 
5
6
  def initialize
6
- @callbacks = {}
7
+ @callbacks = registry(
8
+ :callbacks,
9
+ call: false,
10
+ on_key_already_registered: ->(key) { raise_callback_already_registered(key) }
11
+ )
12
+
7
13
  @result = nil
8
14
  end
9
15
 
@@ -11,8 +17,8 @@ module NxtHttpClient
11
17
  attr_reader :callbacks
12
18
 
13
19
  def eval_callback(target, key, response)
14
- return unless callbacks[key]
15
- target.instance_exec(response, &callbacks[key])
20
+ return unless callbacks.resolve!(key)
21
+ target.instance_exec(response, &callbacks.resolve(key))
16
22
  end
17
23
 
18
24
  def configure(&block)
@@ -20,13 +26,11 @@ module NxtHttpClient
20
26
  end
21
27
 
22
28
  def register_callback(code, overwrite: false, &block)
23
- key = code.to_s
24
- # This would add callbacks to the response handler
25
- unless overwrite
26
- callbacks[key].present? && raise_callback_already_registered(code)
29
+ if overwrite
30
+ callbacks.register!(code, block)
31
+ else
32
+ callbacks.register(code, block)
27
33
  end
28
-
29
- callbacks[key] = block
30
34
  end
31
35
 
32
36
  def register_callback!(code, &block)
@@ -60,10 +64,9 @@ module NxtHttpClient
60
64
  raise CallbackAlreadyRegistered, msg
61
65
  end
62
66
 
63
- # we need to dup callbacks since dup is shallow
64
67
  def initialize_copy(original)
65
68
  super
66
- @callbacks = original.send(:callbacks).dup
69
+ @callbacks = original.send(:callbacks).clone
67
70
  @result = nil
68
71
  end
69
72
  end
@@ -1,3 +1,3 @@
1
1
  module NxtHttpClient
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_dependency 'typhoeus'
39
39
  spec.add_dependency 'activesupport', '~> 6.0.0'
40
+ spec.add_dependency 'nxt_registry'
40
41
 
41
42
  spec.add_development_dependency 'bundler', '~> 1.17'
42
43
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nxt_http_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Robecke
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2019-09-02 00:00:00.000000000 Z
14
+ date: 2020-01-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: typhoeus
@@ -41,6 +41,20 @@ dependencies:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
43
  version: 6.0.0
44
+ - !ruby/object:Gem::Dependency
45
+ name: nxt_registry
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
44
58
  - !ruby/object:Gem::Dependency
45
59
  name: bundler
46
60
  requirement: !ruby/object:Gem::Requirement
@@ -200,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
214
  - !ruby/object:Gem::Version
201
215
  version: '0'
202
216
  requirements: []
203
- rubygems_version: 3.0.1
217
+ rubygems_version: 3.0.6
204
218
  signing_key:
205
219
  specification_version: 4
206
220
  summary: NxtHttpClinet is a simple DSL on top the typhoeus http gem