client-api-builder 0.1.0 → 0.2.0

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: 34ae348684b22669748f3dca2fc9866f2b87247da8452fc5b848e175c1ef74a8
4
- data.tar.gz: 95e6b09d24e961c0ce20a6cc15d3fcdf858f47b2725151838cd8ea5d01df0965
3
+ metadata.gz: 2e5b76aafc223c8695b05460638fbd487b9ee2ad969e690f26de97d1cccf8293
4
+ data.tar.gz: 4b31ea3ef759fd3cf553d32e6b474378137e6b0badc52139068f7db9d7f87b00
5
5
  SHA512:
6
- metadata.gz: e6dd7780a28eec364c787d209fbd37618c6c9f8c7262c1abaa2fbf90b419240657a77bd1a7523388f680643837839162c36a427ca3023ccee986d6f0c1ba3b43
7
- data.tar.gz: 6b407cefa4e351149e881c6f19897f1566b0440684790f26b9df7636a151737c068efd23ced372b8cd0a306179dc6a4c3491de574fdaacdd8b5f90b0b03e5e93
6
+ metadata.gz: bb0d45fe8b4832a73b84a931f63ea3713a955c0d5b44a31159a54b0d454b4b63c0d29d80a379cbbcbd1c469b4b65a9e04ba238650d04e749f28918819987b65a
7
+ data.tar.gz: 752dfdf1071668e456532b1d41c1adcdbd522e09bb6a05a5c904f678a71e62014247ecc6e66a0a51fe8474fc222dee05127e9988406b95e6c5887ee6682f7f23
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 3.0.0
data/Gemfile.lock CHANGED
@@ -1,60 +1,62 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.7.0)
4
+ addressable (2.8.0)
5
5
  public_suffix (>= 2.0.2, < 5.0)
6
- ast (2.4.1)
6
+ ast (2.4.2)
7
7
  crack (0.4.5)
8
8
  rexml
9
9
  diff-lcs (1.4.4)
10
- docile (1.3.2)
10
+ docile (1.4.0)
11
11
  hashdiff (1.0.1)
12
12
  inheritance-helper (0.1.5)
13
- parallel (1.19.2)
14
- parser (2.7.1.4)
13
+ parallel (1.20.1)
14
+ parser (3.0.1.1)
15
15
  ast (~> 2.4.1)
16
16
  public_suffix (4.0.6)
17
17
  rainbow (3.0.0)
18
- rake (13.0.1)
19
- regexp_parser (1.7.1)
20
- rexml (3.2.4)
21
- rspec (3.9.0)
22
- rspec-core (~> 3.9.0)
23
- rspec-expectations (~> 3.9.0)
24
- rspec-mocks (~> 3.9.0)
25
- rspec-core (3.9.2)
26
- rspec-support (~> 3.9.3)
27
- rspec-expectations (3.9.2)
18
+ rake (13.0.3)
19
+ regexp_parser (2.1.1)
20
+ rexml (3.2.5)
21
+ rspec (3.10.0)
22
+ rspec-core (~> 3.10.0)
23
+ rspec-expectations (~> 3.10.0)
24
+ rspec-mocks (~> 3.10.0)
25
+ rspec-core (3.10.1)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-expectations (3.10.1)
28
28
  diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.9.0)
30
- rspec-mocks (3.9.1)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-mocks (3.10.2)
31
31
  diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.9.0)
33
- rspec-support (3.9.3)
34
- rubocop (0.87.1)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-support (3.10.2)
34
+ rubocop (1.18.2)
35
35
  parallel (~> 1.10)
36
- parser (>= 2.7.1.1)
36
+ parser (>= 3.0.0.0)
37
37
  rainbow (>= 2.2.2, < 4.0)
38
- regexp_parser (>= 1.7)
38
+ regexp_parser (>= 1.8, < 3.0)
39
39
  rexml
40
- rubocop-ast (>= 0.1.0, < 1.0)
40
+ rubocop-ast (>= 1.7.0, < 2.0)
41
41
  ruby-progressbar (~> 1.7)
42
- unicode-display_width (>= 1.4.0, < 2.0)
43
- rubocop-ast (0.1.0)
44
- parser (>= 2.7.0.1)
45
- ruby-progressbar (1.10.1)
46
- simplecov (0.18.5)
42
+ unicode-display_width (>= 1.4.0, < 3.0)
43
+ rubocop-ast (1.7.0)
44
+ parser (>= 3.0.1.1)
45
+ ruby-progressbar (1.11.0)
46
+ simplecov (0.21.2)
47
47
  docile (~> 1.1)
48
48
  simplecov-html (~> 0.11)
49
- simplecov-html (0.12.2)
50
- unicode-display_width (1.7.0)
51
- webmock (3.11.1)
49
+ simplecov_json_formatter (~> 0.1)
50
+ simplecov-html (0.12.3)
51
+ simplecov_json_formatter (0.1.3)
52
+ unicode-display_width (2.0.0)
53
+ webmock (3.13.0)
52
54
  addressable (>= 2.3.6)
53
55
  crack (>= 0.3.2)
54
56
  hashdiff (>= 0.4.0, < 2.0.0)
55
57
 
56
58
  PLATFORMS
57
- ruby
59
+ x86_64-darwin-20
58
60
 
59
61
  DEPENDENCIES
60
62
  inheritance-helper
@@ -65,4 +67,4 @@ DEPENDENCIES
65
67
  webmock
66
68
 
67
69
  BUNDLED WITH
68
- 2.1.4
70
+ 2.2.3
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'client-api-builder'
5
- s.version = '0.1.0'
5
+ s.version = '0.2.0'
6
6
  s.licenses = ['MIT']
7
7
  s.summary = 'Develop Client API libraries faster'
8
8
  s.description = 'Utility for constructing API clients'
@@ -38,9 +38,9 @@ module ClientApiBuilder
38
38
  add_value_to_class_method(:default_options, query_builder: builder)
39
39
  end
40
40
 
41
- def header(name, value)
41
+ def header(name, value = nil, &block)
42
42
  headers = default_options[:headers].dup
43
- headers[name] = value
43
+ headers[name] = value || block
44
44
  add_value_to_class_method(:default_options, headers: headers)
45
45
  end
46
46
 
@@ -211,11 +211,23 @@ module ClientApiBuilder
211
211
  end
212
212
 
213
213
  def build_headers(options)
214
- if options[:headers]
215
- self.class.headers.merge(options[:headers])
216
- else
217
- self.class.headers
214
+ headers = {}
215
+
216
+ add_header_proc = proc do |name, value|
217
+ headers[name] =
218
+ if value.is_a?(Proc)
219
+ instance_eval(&value)
220
+ elsif value.is_a?(Symbol)
221
+ send(value)
222
+ else
223
+ value
224
+ end
218
225
  end
226
+
227
+ self.class.headers.each(&add_header_proc)
228
+ options[:headers]&.each(&add_header_proc)
229
+
230
+ headers
219
231
  end
220
232
 
221
233
  def build_connection_options(options)
@@ -257,7 +269,16 @@ module ClientApiBuilder
257
269
  end
258
270
 
259
271
  def handle_response(response, options, &block)
260
- data = parse_response(response, options)
272
+ data =
273
+ case options[:return]
274
+ when :response
275
+ response
276
+ when :body
277
+ response.body
278
+ else
279
+ parse_response(response, options)
280
+ end
281
+
261
282
  if block
262
283
  instance_exec(data, &block)
263
284
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client-api-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Utility for constructing API clients
14
14
  email: dougyouch@gmail.com
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  requirements: []
51
- rubygems_version: 3.1.2
51
+ rubygems_version: 3.2.3
52
52
  signing_key:
53
53
  specification_version: 4
54
54
  summary: Develop Client API libraries faster