katinguele 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/katinguele/client/builder.rb +20 -12
- data/lib/katinguele/client/requester.rb +8 -0
- data/lib/katinguele/version.rb +1 -1
- 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: cc4e75582da95c103a61bb1ae12455172080a71ea6b92677dc9af7f403a3bc6a
|
4
|
+
data.tar.gz: f821ffbc534f81e71cac0f9c788f1dbec40cb2fc9c39f1d8c3011d08e72dc0ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be720499d4655b68a9c331966113717930b72a220b39d6cf7755f5b4d62a11c0dfcb0c688629bad9f25510d6e5ae65c0748e82f2ecc29b103dc3a90924035b8c
|
7
|
+
data.tar.gz: 13a7cc2dcb924fd1d783369fbce56958f1543286f03d88b65582e4133e022621be271e3c414e7902b2ade1162ea3508539b2b96665bb8fc5268a3e7089368cd9
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Katinguele
|
4
4
|
module Client
|
5
|
-
class
|
5
|
+
class UnknownService < StandardError; end
|
6
6
|
|
7
7
|
module Builder
|
8
8
|
def self.extended(base)
|
@@ -15,8 +15,8 @@ module Katinguele
|
|
15
15
|
build_katinguele_request_options(options)
|
16
16
|
end
|
17
17
|
|
18
|
-
def katinguele_service(name)
|
19
|
-
build_katinguele_service(name)
|
18
|
+
def katinguele_service(name, options = {})
|
19
|
+
build_katinguele_service(name, { lazy: false }.merge(options || {}))
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -30,31 +30,39 @@ module Katinguele
|
|
30
30
|
build_katinguele_request
|
31
31
|
end
|
32
32
|
|
33
|
-
def build_katinguele_service(name = nil)
|
33
|
+
def build_katinguele_service(name = nil, options = {})
|
34
34
|
katinguele_options[:service_name] ||= name
|
35
|
+
katinguele_options[:service_options] ||= options
|
35
36
|
build_katinguele_request
|
36
37
|
end
|
37
38
|
|
38
|
-
def build_katinguele_request
|
39
|
+
def build_katinguele_request(force = false)
|
39
40
|
Katinguele.configuration
|
40
41
|
.find_service(katinguele_options[:service_name])
|
41
|
-
.then { |service| handle_unknown_service!(service) }
|
42
|
-
.then { |service| create_request(service) }
|
42
|
+
.then { |service| handle_unknown_service!(service, force) }
|
43
|
+
.then { |service| create_request(service, force) }
|
43
44
|
.then { |request| katinguele_options[:request] = request }
|
44
|
-
|
45
|
+
.then { build_katinguele_request_attributes }
|
45
46
|
end
|
46
47
|
|
47
48
|
def build_katinguele_request_attributes
|
48
|
-
define_singleton_method(:katinguele_request_attributes) { katinguele_options&.[](:request)&.attributes }
|
49
|
+
define_singleton_method(:katinguele_request_attributes) { katinguele_options&.[](:request)&.attributes || {} }
|
49
50
|
end
|
50
51
|
|
51
|
-
def handle_unknown_service!(service)
|
52
|
-
|
52
|
+
def handle_unknown_service!(service, force)
|
53
|
+
return unless take_request?(force)
|
54
|
+
raise UnknownService if !service && katinguele_options[:service_name]
|
53
55
|
|
54
56
|
service
|
55
57
|
end
|
56
58
|
|
57
|
-
def
|
59
|
+
def take_request?(force)
|
60
|
+
!katinguele_options.dig(:service_options, :lazy) || force
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_request(service, force)
|
64
|
+
return unless take_request?(force)
|
65
|
+
|
58
66
|
Katinguele.configuration.request_by(service, katinguele_options[:request_options])
|
59
67
|
end
|
60
68
|
end
|
@@ -36,6 +36,8 @@ module Katinguele
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def build_final_request(options, method)
|
39
|
+
build_katinguele_request_lazy
|
40
|
+
|
39
41
|
Katinguele.configuration
|
40
42
|
.request_by(katinguele_options[:request], options)
|
41
43
|
.tap do |request|
|
@@ -45,6 +47,12 @@ module Katinguele
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
50
|
+
def build_katinguele_request_lazy
|
51
|
+
return unless katinguele_options.dig(:service_options, :lazy)
|
52
|
+
|
53
|
+
build_katinguele_request(true)
|
54
|
+
end
|
55
|
+
|
48
56
|
def rescue_faraday_error?(req, res, err)
|
49
57
|
req.after!(req, res, err) || (err.is_a?(Katinguele::TimeoutError) && !req.raise_error)
|
50
58
|
end
|
data/lib/katinguele/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katinguele
|
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
|
- linqueta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|