my_api_client 0.19.0 → 0.20.0

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: 5609ea96b6fa8a515176a95b02ffedf732d4d1fe79a0885ed5a893c804000df7
4
- data.tar.gz: ae8465d2dedbd0f1c3f06d2c00ede391959ed710c2c60cc00830bee2ba88975f
3
+ metadata.gz: 679868aa1b5a2bc6deb75bfcca9a7882d04c2739871c328510a741823fed3e8e
4
+ data.tar.gz: c286ec47b78171cf478b53568ab6ade3f618204d2b5223ddad32e35e2715fd6b
5
5
  SHA512:
6
- metadata.gz: 57d9a99fcba5b23a291817626d2d1813d3867335ce9129f74b2208cbed97c1b0ab9e63ee6ca3174f64bfacd43d3c6ff1d27e3c635e467d155c07772205816bb4
7
- data.tar.gz: 63eb822667774d43a146407d413a873ddca0361f9aac1c1afad687a65626cc8fb5f5f162ba150cf08622a0f0ad8b0aec47daa32c4331c21f6dc3cf8dc60356bb
6
+ metadata.gz: 14ee86532b34852778e544a61a50ffdd1ef9b73ae6a6efcf51b7dbb0fcce9e9395d62b53eda6656730bd488b6547cf3471add7d62c6bd2edd1863aa92a4f993c
7
+ data.tar.gz: da243fd8ab63338bd8e727dc6125b9ecd9c5d361db10fc6d7716af4996ac8b745ac30a88a9bceac8c5d4f7ad0a88badbe01a0ddf140267f4db77173439b496dc
data/.circleci/config.yml CHANGED
@@ -12,12 +12,12 @@ references:
12
12
  - &ruby_version
13
13
  ruby_version:
14
14
  type: enum
15
- enum: ['2.5', '2.6', '2.7', '3.0']
15
+ enum: &ruby_version_enum ['2.5', '2.6', '2.7', '3.0']
16
16
  default: '3.0'
17
17
  - &rails_version
18
18
  rails_version:
19
19
  type: enum
20
- enum: ['5.2', '6.0', '6.1']
20
+ enum: &rails_version_enum ['5.2', '6.0', '6.1']
21
21
  default: '6.1'
22
22
  - &bundler_options
23
23
  bundler_options:
@@ -92,7 +92,7 @@ commands:
92
92
  - code-climate/format-coverage:
93
93
  input-type: simplecov
94
94
  prefix: $(readlink -f .)
95
- coverage-file: coverage/.resultset.json
95
+ coverage-file: coverage/coverage.json
96
96
  output: coverage/codeclimate.$CIRCLE_BUILD_NUM.json
97
97
  - persist_to_workspace:
98
98
  root: coverage
@@ -248,7 +248,7 @@ jobs:
248
248
  - code-climate/install
249
249
  - code-climate/sum-coverage:
250
250
  input: codeclimate.*.json
251
- parts: 13
251
+ parts: 24
252
252
  - code-climate/upload-coverage
253
253
  rubocop:
254
254
  executor: gem_executor
@@ -277,151 +277,37 @@ workflows:
277
277
  commit:
278
278
  jobs:
279
279
  - build_gem:
280
- name: build_on_ruby_2.5_and_rails_5.2
281
- ruby_version: '2.5'
282
- rails_version: '5.2'
283
- - build_gem:
284
- name: build_on_ruby_2.5_and_rails_6.0
285
- ruby_version: '2.5'
286
- rails_version: '6.0'
287
- - build_gem:
288
- name: build_on_ruby_2.5_and_rails_6.1
289
- ruby_version: '2.5'
290
- rails_version: '6.1'
291
- - build_gem:
292
- name: build_on_ruby_2.6_and_rails_5.2
293
- ruby_version: '2.6'
294
- rails_version: '5.2'
295
- - build_gem:
296
- name: build_on_ruby_2.6_and_rails_6.0
297
- ruby_version: '2.6'
298
- rails_version: '6.0'
299
- - build_gem:
300
- name: build_on_ruby_2.6_and_rails_6.1
301
- ruby_version: '2.6'
302
- rails_version: '6.1'
303
- - build_gem:
304
- name: build_on_ruby_2.7_and_rails_5.2
305
- ruby_version: '2.7'
306
- rails_version: '5.2'
307
- - build_gem:
308
- name: build_on_ruby_2.7_and_rails_6.0
309
- ruby_version: '2.7'
310
- rails_version: '6.0'
311
- - build_gem:
312
- name: build_on_ruby_2.7_and_rails_6.1_with_integrations
313
- ruby_version: '2.7'
314
- rails_version: '6.1'
315
- bundler_options: '--with integrations'
316
- - build_gem:
317
- name: build_on_ruby_2.7_and_rails_6.1_without_integrations
318
- ruby_version: '2.7'
319
- rails_version: '6.1'
320
- bundler_options: '--without integrations'
321
- - build_gem:
322
- name: build_on_ruby_3.0_and_rails_6.0
323
- ruby_version: '3.0'
324
- rails_version: '6.0'
325
- - build_gem:
326
- name: build_on_ruby_3.0_and_rails_6.1_with_integrations
327
- ruby_version: '3.0'
328
- rails_version: '6.1'
329
- bundler_options: '--with integrations'
330
- - build_gem:
331
- name: build_on_ruby_3.0_and_rails_6.1_without_integrations
332
- ruby_version: '3.0'
333
- rails_version: '6.1'
334
- bundler_options: '--without integrations'
335
- - verify_generator:
336
- name: verify_generator_on_ruby_2.5_and_rails_5.2
337
- ruby_version: '2.5'
338
- rails_version: '5.2'
339
- - verify_generator:
340
- name: verify_generator_on_ruby_2.5_and_rails_6.0
341
- ruby_version: '2.5'
342
- rails_version: '6.0'
343
- - verify_generator:
344
- name: verify_generator_on_ruby_2.5_and_rails_6.1
345
- ruby_version: '2.5'
346
- rails_version: '6.1'
347
- - verify_generator:
348
- name: verify_generator_on_ruby_2.6_and_rails_5.2
349
- ruby_version: '2.6'
350
- rails_version: '5.2'
351
- - verify_generator:
352
- name: verify_generator_on_ruby_2.6_and_rails_6.0
353
- ruby_version: '2.6'
354
- rails_version: '6.0'
355
- - verify_generator:
356
- name: verify_generator_on_ruby_2.6_and_rails_6.1
357
- ruby_version: '2.6'
358
- rails_version: '6.1'
359
- - verify_generator:
360
- name: verify_generator_on_ruby_2.7_and_rails_5.2
361
- ruby_version: '2.7'
362
- rails_version: '5.2'
363
- - verify_generator:
364
- name: verify_generator_on_ruby_2.7_and_rails_6.0
365
- ruby_version: '2.7'
366
- rails_version: '6.0'
367
- - verify_generator:
368
- name: verify_generator_on_ruby_2.7_and_rails_6.1
369
- ruby_version: '2.7'
370
- rails_version: '6.1'
371
- - verify_generator:
372
- name: verify_generator_on_ruby_3.0_and_rails_6.0
373
- ruby_version: '3.0'
374
- rails_version: '6.0'
280
+ name: build_on_ruby_<< matrix.ruby_version >>_and_rails_<< matrix.rails_version >><< matrix.bundler_options >>
281
+ matrix:
282
+ parameters:
283
+ ruby_version: *ruby_version_enum
284
+ rails_version: *rails_version_enum
285
+ bundler_options: ['--with integrations', '--without integrations']
286
+ exclude:
287
+ - ruby_version: '3.0'
288
+ rails_version: '5.2'
375
289
  - verify_generator:
376
- name: verify_generator_on_ruby_3.0_and_rails_6.1
377
- ruby_version: '3.0'
378
- rails_version: '6.1'
290
+ name: verify_generator_on_ruby_<< matrix.ruby_version >>_and_rails_<< matrix.rails_version >>
291
+ matrix:
292
+ parameters:
293
+ ruby_version: *ruby_version_enum
294
+ rails_version: *rails_version_enum
295
+ exclude:
296
+ - ruby_version: '3.0'
297
+ rails_version: '5.2'
379
298
  - test_api:
380
299
  ruby_version: '2.7' # Jets supports only Ruby 2.x
381
300
  - rubocop
382
301
  - yardoc
383
302
  - upload-coverage:
384
303
  requires:
385
- - build_on_ruby_2.5_and_rails_5.2
386
- - build_on_ruby_2.5_and_rails_6.0
387
- - build_on_ruby_2.5_and_rails_6.1
388
- - build_on_ruby_2.6_and_rails_5.2
389
- - build_on_ruby_2.6_and_rails_6.0
390
- - build_on_ruby_2.6_and_rails_6.1
391
- - build_on_ruby_2.7_and_rails_5.2
392
- - build_on_ruby_2.7_and_rails_6.0
393
- - build_on_ruby_2.7_and_rails_6.1_with_integrations
394
- - build_on_ruby_2.7_and_rails_6.1_without_integrations
395
- - build_on_ruby_3.0_and_rails_6.0
396
- - build_on_ruby_3.0_and_rails_6.1_with_integrations
397
- - build_on_ruby_3.0_and_rails_6.1_without_integrations
304
+ - build_gem
305
+ - verify_generator # for GitHub requirements
398
306
  - release:
399
307
  context: RubyGems API Key
400
308
  requires:
401
- - build_on_ruby_2.5_and_rails_5.2
402
- - build_on_ruby_2.5_and_rails_6.0
403
- - build_on_ruby_2.5_and_rails_6.1
404
- - build_on_ruby_2.6_and_rails_5.2
405
- - build_on_ruby_2.6_and_rails_6.0
406
- - build_on_ruby_2.6_and_rails_6.1
407
- - build_on_ruby_2.7_and_rails_5.2
408
- - build_on_ruby_2.7_and_rails_6.0
409
- - build_on_ruby_2.7_and_rails_6.1_with_integrations
410
- - build_on_ruby_2.7_and_rails_6.1_without_integrations
411
- - build_on_ruby_3.0_and_rails_6.0
412
- - build_on_ruby_3.0_and_rails_6.1_with_integrations
413
- - build_on_ruby_3.0_and_rails_6.1_without_integrations
414
- - verify_generator_on_ruby_2.5_and_rails_5.2
415
- - verify_generator_on_ruby_2.5_and_rails_6.0
416
- - verify_generator_on_ruby_2.5_and_rails_6.1
417
- - verify_generator_on_ruby_2.6_and_rails_5.2
418
- - verify_generator_on_ruby_2.6_and_rails_6.0
419
- - verify_generator_on_ruby_2.6_and_rails_6.1
420
- - verify_generator_on_ruby_2.7_and_rails_5.2
421
- - verify_generator_on_ruby_2.7_and_rails_6.0
422
- - verify_generator_on_ruby_2.7_and_rails_6.1
423
- - verify_generator_on_ruby_3.0_and_rails_6.0
424
- - verify_generator_on_ruby_3.0_and_rails_6.1
309
+ - build_gem
310
+ - verify_generator
425
311
  - rubocop
426
312
  filters:
427
313
  branches:
data/.gem_comet.yml CHANGED
@@ -1,12 +1,23 @@
1
1
  # [Usage]
2
2
  #
3
3
  # $ gem install gem_comet
4
+ # $ gem_comet init
4
5
  # $ gem_comet release {version number, like as "1.2.3"}
6
+ # $ gem_comet changelog
7
+ # $ gem_comet versions
5
8
 
6
- version: 1.1
7
-
9
+ version: 1.2
8
10
  release:
9
11
  base_branch: master
10
12
  release_branch: release
11
13
  version_file_path: lib/my_api_client/version.rb
12
14
  changelog_file_path: CHANGELOG.md # optional
15
+ changelog:
16
+ categories:
17
+ - Feature
18
+ - Bugfix
19
+ - Security
20
+ - Breaking Change
21
+ - Rubocop Challenge
22
+ - Dependabot
23
+ - Misc
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-12-25 23:31:13 UTC using RuboCop version 1.7.0.
3
+ # on 2021-03-01 23:31:18 UTC using RuboCop version 1.11.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -43,17 +43,3 @@ Style/DocumentDynamicEvalDefinition:
43
43
  - 'lib/my_api_client/config.rb'
44
44
  - 'lib/my_api_client/request/basic.rb'
45
45
  - 'lib/my_api_client/request/logger.rb'
46
-
47
- # Offense count: 1
48
- # Cop supports --auto-correct.
49
- Style/HashTransformValues:
50
- Exclude:
51
- - 'lib/my_api_client/integrations/bugsnag.rb'
52
-
53
- # Offense count: 3
54
- # Cop supports --auto-correct.
55
- Style/StringConcatenation:
56
- Exclude:
57
- - 'lib/my_api_client/request.rb'
58
- - 'lib/my_api_client/rspec/matchers/request_to.rb'
59
- - 'my_api/app/controllers/pagination_controller.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Change log
2
2
 
3
+ ## v0.20.0 (Mar 07, 2021)
4
+
5
+ ### Feature
6
+
7
+ * [#456](https://github.com/ryz310/my_api_client/pull/456) Stubbed pagination ([@ryz310](https://github.com/ryz310))
8
+
9
+ ### Rubocop Challenge
10
+
11
+ * [#414](https://github.com/ryz310/my_api_client/pull/414) Style/StringConcatenation-20210106033935 ([@ryz310](https://github.com/ryz310))
12
+ * [#416](https://github.com/ryz310/my_api_client/pull/416) Style/HashTransformValues-20210106233116 ([@ryz310](https://github.com/ryz310))
13
+ * [#433](https://github.com/ryz310/my_api_client/pull/433) Lint/SymbolConversion-20210128233108 ([@ryz310](https://github.com/ryz310))
14
+ * [#452](https://github.com/ryz310/my_api_client/pull/452) Re-generate .rubocop_todo.yml with RuboCop v1.11.0 ([@ryz310](https://github.com/ryz310))
15
+
16
+ ### Dependabot
17
+
18
+ * [#415](https://github.com/ryz310/my_api_client/pull/415) ryz310/dependabot/bundler/bugsnag-6.19.0 ([@ryz310](https://github.com/ryz310))
19
+ * [#421](https://github.com/ryz310/my_api_client/pull/421) Update simplecov requirement from = 0.17.1 to = 0.21.2 ([@ryz310](https://github.com/ryz310))
20
+ * [#427](https://github.com/ryz310/my_api_client/pull/427) ryz310/dependabot/bundler/my_api/jets-3.0.2 ([@ryz310](https://github.com/ryz310))
21
+ * [#426](https://github.com/ryz310/my_api_client/pull/426) ryz310/dependabot/bundler/my_api/nokogiri-1.11.0 ([@ryz310](https://github.com/ryz310))
22
+ * [#435](https://github.com/ryz310/my_api_client/pull/435) ryz310/dependabot/bundler/my_api/capybara-3.35.3 ([@ryz310](https://github.com/ryz310))
23
+ * [#440](https://github.com/ryz310/my_api_client/pull/440) ryz310/dependabot/bundler/rubocop-rspec-2.2.0 ([@ryz310](https://github.com/ryz310))
24
+ * [#444](https://github.com/ryz310/my_api_client/pull/444) ryz310/dependabot/bundler/my_api/actionpack-6.1.2.1 ([@ryz310](https://github.com/ryz310))
25
+ * [#447](https://github.com/ryz310/my_api_client/pull/447) ryz310/dependabot/bundler/activesupport-6.1.3 ([@ryz310](https://github.com/ryz310))
26
+ * [#453](https://github.com/ryz310/my_api_client/pull/453) ryz310/dependabot/bundler/rubocop-performance-1.10.1 ([@ryz310](https://github.com/ryz310))
27
+ * [#454](https://github.com/ryz310/my_api_client/pull/454) ryz310/dependabot/bundler/my_api/puma-5.2.2 ([@ryz310](https://github.com/ryz310))
28
+ * [#455](https://github.com/ryz310/my_api_client/pull/455) ryz310/dependabot/bundler/webmock-3.12.1 ([@ryz310](https://github.com/ryz310))
29
+
30
+ ### Misc
31
+
32
+ * [#436](https://github.com/ryz310/my_api_client/pull/436) Use Circle CI matrix ([@ryz310](https://github.com/ryz310))
33
+
3
34
  ## v0.19.0 (Jan 04, 2021)
4
35
 
5
36
  ### Feature
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (0.19.0)
4
+ my_api_client (0.20.0)
5
5
  activesupport (>= 5.2.0)
6
6
  faraday (>= 0.17.1)
7
7
  jsonpath
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (6.1.0)
13
+ activesupport (6.1.3)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
@@ -18,29 +18,28 @@ GEM
18
18
  zeitwerk (~> 2.3)
19
19
  addressable (2.7.0)
20
20
  public_suffix (>= 2.0.2, < 5.0)
21
- ast (2.4.1)
22
- bugsnag (6.18.0)
21
+ ast (2.4.2)
22
+ bugsnag (6.19.0)
23
23
  concurrent-ruby (~> 1.0)
24
24
  byebug (11.1.3)
25
25
  coderay (1.1.3)
26
- concurrent-ruby (1.1.7)
26
+ concurrent-ruby (1.1.8)
27
27
  crack (0.4.5)
28
28
  rexml
29
29
  diff-lcs (1.4.4)
30
- docile (1.3.4)
30
+ docile (1.3.5)
31
31
  faraday (1.3.0)
32
32
  faraday-net_http (~> 1.0)
33
33
  multipart-post (>= 1.2, < 3)
34
34
  ruby2_keywords
35
- faraday-net_http (1.0.0)
35
+ faraday-net_http (1.0.1)
36
36
  hashdiff (1.0.1)
37
- i18n (1.8.7)
37
+ i18n (1.8.9)
38
38
  concurrent-ruby (~> 1.0)
39
- json (2.5.1)
40
39
  jsonpath (1.1.0)
41
40
  multi_json
42
41
  method_source (1.0.0)
43
- minitest (5.14.2)
42
+ minitest (5.14.4)
44
43
  multi_json (1.15.0)
45
44
  multipart-post (2.1.1)
46
45
  parallel (1.20.1)
@@ -55,7 +54,7 @@ GEM
55
54
  public_suffix (4.0.6)
56
55
  rainbow (3.0.0)
57
56
  rake (13.0.3)
58
- regexp_parser (2.0.3)
57
+ regexp_parser (2.1.1)
59
58
  rexml (3.2.4)
60
59
  rspec (3.10.0)
61
60
  rspec-core (~> 3.10.0)
@@ -66,43 +65,44 @@ GEM
66
65
  rspec-expectations (3.10.1)
67
66
  diff-lcs (>= 1.2.0, < 2.0)
68
67
  rspec-support (~> 3.10.0)
69
- rspec-mocks (3.10.1)
68
+ rspec-mocks (3.10.2)
70
69
  diff-lcs (>= 1.2.0, < 2.0)
71
70
  rspec-support (~> 3.10.0)
72
- rspec-support (3.10.1)
71
+ rspec-support (3.10.2)
73
72
  rspec_junit_formatter (0.4.1)
74
73
  rspec-core (>= 2, < 4, != 2.12.0)
75
- rubocop (1.7.0)
74
+ rubocop (1.11.0)
76
75
  parallel (~> 1.10)
77
- parser (>= 2.7.1.5)
76
+ parser (>= 3.0.0.0)
78
77
  rainbow (>= 2.2.2, < 4.0)
79
78
  regexp_parser (>= 1.8, < 3.0)
80
79
  rexml
81
80
  rubocop-ast (>= 1.2.0, < 2.0)
82
81
  ruby-progressbar (~> 1.7)
83
- unicode-display_width (>= 1.4.0, < 2.0)
84
- rubocop-ast (1.4.0)
82
+ unicode-display_width (>= 1.4.0, < 3.0)
83
+ rubocop-ast (1.4.1)
85
84
  parser (>= 2.7.1.5)
86
- rubocop-performance (1.9.2)
85
+ rubocop-performance (1.10.1)
87
86
  rubocop (>= 0.90.0, < 2.0)
88
87
  rubocop-ast (>= 0.4.0)
89
- rubocop-rspec (2.1.0)
88
+ rubocop-rspec (2.2.0)
90
89
  rubocop (~> 1.0)
91
90
  rubocop-ast (>= 1.1.0)
92
91
  ruby-progressbar (1.11.0)
93
- ruby2_keywords (0.0.2)
92
+ ruby2_keywords (0.0.4)
94
93
  sawyer (0.8.2)
95
94
  addressable (>= 2.3.5)
96
95
  faraday (> 0.8, < 2.0)
97
- simplecov (0.17.1)
96
+ simplecov (0.21.2)
98
97
  docile (~> 1.1)
99
- json (>= 1.8, < 3)
100
- simplecov-html (~> 0.10.0)
101
- simplecov-html (0.10.2)
98
+ simplecov-html (~> 0.11)
99
+ simplecov_json_formatter (~> 0.1)
100
+ simplecov-html (0.12.3)
101
+ simplecov_json_formatter (0.1.2)
102
102
  tzinfo (2.0.4)
103
103
  concurrent-ruby (~> 1.0)
104
- unicode-display_width (1.7.0)
105
- webmock (3.11.0)
104
+ unicode-display_width (2.0.0)
105
+ webmock (3.12.1)
106
106
  addressable (>= 2.3.6)
107
107
  crack (>= 0.3.2)
108
108
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -123,7 +123,7 @@ DEPENDENCIES
123
123
  rubocop
124
124
  rubocop-performance
125
125
  rubocop-rspec
126
- simplecov (= 0.17.1)
126
+ simplecov (= 0.21.2)
127
127
  webmock
128
128
  yard
129
129
 
data/README.jp.md CHANGED
@@ -551,6 +551,8 @@ end
551
551
 
552
552
  ### Stubbing
553
553
 
554
+ #### `response` option
555
+
554
556
  以下のような `ApiClient` を定義しているとします。
555
557
 
556
558
  ```ruby
@@ -587,6 +589,7 @@ response = ExampleApiClient.new.request(user_id: 1)
587
589
  response.id # => 12345
588
590
  ```
589
591
 
592
+ #### Proc
590
593
 
591
594
  リクスエストパラメータを使ったレスポンスを返すようにスタブ化したい場合は、 `Proc` を利用することで実現できます。
592
595
 
@@ -600,7 +603,9 @@ response = ExampleApiClient.new.request(user_id: 1)
600
603
  response.id # => 1
601
604
  ```
602
605
 
603
- `receive` `have_received` を使ったテストを書きたい場合は、 `stub_api_client_all` `stub_api_client` の戻り値を利用すると良いでしょう。
606
+ #### Return value of `#stub_api_client_all` and `#stub_api_client`
607
+
608
+ `#stub_api_client_all` や `#stub_api_client` の戻り値はスタブ化した API Client のスタブオブジェクトです。`receive` や `have_received` を使ったテストを書きたい場合は、これらの値を利用すると良いでしょう。
604
609
 
605
610
  ```ruby
606
611
  def execute_api_request
@@ -612,7 +617,9 @@ execute_api_request
612
617
  expect(api_client).to have_received(:request).with(user_id: 1)
613
618
  ```
614
619
 
615
- また、例外が発生する場合のテストを書きたい場合は、 `raise` オプションを利用することができます。
620
+ #### `raise` option
621
+
622
+ 例外が発生する場合のテストを書きたい場合は、 `raise` オプションを利用することができます。
616
623
 
617
624
  ```ruby
618
625
  def execute_api_request
@@ -642,6 +649,60 @@ rescue MyApiClient::Error => e
642
649
  end
643
650
  ```
644
651
 
652
+ #### `pageable` option
653
+
654
+ `#pageable_get` (`#pget`) を使った実装用に `pageable` というオプションが利用できます。
655
+ `pageable` に設定する値は `Enumerable` である必要があります。
656
+
657
+ ```ruby
658
+ stub_api_client_all(
659
+ MyPaginationApiClient,
660
+ pagination: {
661
+ pageable: [
662
+ { page: 1 },
663
+ { page: 2 },
664
+ { page: 3 },
665
+ ],
666
+ }
667
+ )
668
+
669
+ MyPaginationApiClient.new.pagination.each do |response|
670
+ response.page #=> 1, 2, 3
671
+ end
672
+ ```
673
+
674
+ なお、 `Enumerable` の各値にはここまで紹介した `response`, `raise`, `Prox` など全てのオプションが利用可能です。
675
+
676
+ ```ruby
677
+ stub_api_client_all(
678
+ MyPaginationApiClient,
679
+ pagination: {
680
+ pageable: [
681
+ { response: { page: 1 } },
682
+ { page: 2 },
683
+ ->(params) { { page: 3, user_id: params[:user_id] } },
684
+ { raise: MyApiClient::ClientError::IamTeapot },
685
+ ],
686
+ }
687
+ )
688
+ ```
689
+
690
+ また、 `Enumerator` を使えば無限に続くページネーションを定義することもできます。
691
+
692
+
693
+ ```ruby
694
+ stub_api_client_all(
695
+ MyPaginationApiClient,
696
+ pagination: {
697
+ pageable: Enumerator.new do |y|
698
+ loop.with_index(1) do |_, i|
699
+ y << { page: i }
700
+ end
701
+ end,
702
+ }
703
+ )
704
+ ```
705
+
645
706
  ## Deployment
646
707
 
647
708
  この gem のリリースには [gem_comet](https://github.com/ryz310/gem_comet) を利用しています。
@@ -11,7 +11,7 @@ module MyApiClient
11
11
 
12
12
  Bugsnag.leave_breadcrumb(
13
13
  "#{self.class.name} occurred",
14
- metadata.each_with_object({}) { |(k, v), memo| memo[k] = v.inspect },
14
+ metadata.transform_values(&:inspect),
15
15
  Bugsnag::Breadcrumbs::ERROR_BREADCRUMB_TYPE
16
16
  )
17
17
  end
@@ -24,7 +24,7 @@ module MyApiClient
24
24
  # @return [Sawyer::Response]
25
25
  # Response instance.
26
26
  def _request_with_relative_uri(http_method, pathname, headers, query, body)
27
- query_strings = query.present? ? '?' + query&.to_query : ''
27
+ query_strings = query.present? ? "?#{query.to_query}" : ''
28
28
  uri = URI.join(File.join(endpoint, pathname), query_strings)
29
29
  _request_with_absolute_uri(http_method, uri, headers, body)
30
30
  end
@@ -50,7 +50,7 @@ RSpec::Matchers.define :request_to do |expected_method, expected_url|
50
50
  end
51
51
 
52
52
  def request_line(method, url, query = nil)
53
- url += '?' + query.to_query if query.present?
53
+ url += "?#{query.to_query}" if query.present?
54
54
  "#{method.upcase} #{url}"
55
55
  end
56
56
 
@@ -18,6 +18,9 @@ module MyApiClient
18
18
  # @example
19
19
  # stub_api_client_all(
20
20
  # ExampleApiClient,
21
+ # get_users: { # Returns an arbitrary pageable response
22
+ # pageable: [ { id: 1 }, { id: 2 }] # for `#pageable_get`.
23
+ # },
21
24
  # get_user: { response: { id: 1 } }, # Returns an arbitrary response.
22
25
  # post_users: { id: 1 }, # You can ommit `response` keyword.
23
26
  # patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
@@ -46,6 +49,9 @@ module MyApiClient
46
49
  # @example
47
50
  # api_client = stub_api_client(
48
51
  # ExampleApiClient,
52
+ # get_users: { # Returns an arbitrary pageable response
53
+ # pageable: [ { id: 1 }, { id: 2 }] # for `#pageable_get`.
54
+ # },
49
55
  # get_user: { response: { id: 1 } }, # Returns an arbitrary response.
50
56
  # post_users: { id: 1 }, # You can ommit `response` keyword.
51
57
  # patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
@@ -67,25 +73,40 @@ module MyApiClient
67
73
 
68
74
  private
69
75
 
70
- # rubocop:disable Metrics/AbcSize
71
76
  def stubbing(instance, action, options)
77
+ allow(instance).to receive(action) do |*request|
78
+ generate_stubbed_response(options, *request)
79
+ end
80
+ end
81
+
82
+ def generate_stubbed_response(options, *request) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
72
83
  case options
73
84
  when Proc
74
- allow(instance).to receive(action) { |*request| stub_as_resource(options.call(*request)) }
85
+ stub_as_resource(options.call(*request))
75
86
  when Hash
76
- if options[:raise].present?
77
- exception = process_raise_option(options[:raise], options[:response])
78
- allow(instance).to receive(action).and_raise(exception)
87
+ if options[:raise] # rubocop:disable Style/GuardClause
88
+ raise process_raise_option(options[:raise], options[:response])
79
89
  elsif options[:response]
80
- allow(instance).to receive(action).and_return(stub_as_resource(options[:response]))
90
+ stub_as_resource(options[:response])
91
+ elsif options[:pageable].is_a?(Enumerable)
92
+ stub_as_pageable_resource(options[:pageable].each, *request)
81
93
  else
82
- allow(instance).to receive(action).and_return(stub_as_resource(options))
94
+ stub_as_resource(options)
83
95
  end
84
96
  else
85
- allow(instance).to receive(action).and_return(stub_as_resource(options))
97
+ stub_as_resource(options)
86
98
  end
87
99
  end
88
- # rubocop:enable Metrics/AbcSize
100
+
101
+ def stub_as_pageable_resource(pager, *request)
102
+ Enumerator.new do |y|
103
+ loop do
104
+ y << generate_stubbed_response(pager.next, *request)
105
+ rescue StopIteration
106
+ break
107
+ end
108
+ end.lazy
109
+ end
89
110
 
90
111
  # Provides a shorthand for `raise` option.
91
112
  # `MyApiClient::Error` requires `MyApiClient::Params::Params` instance on
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyApiClient
4
- VERSION = '0.19.0'
4
+ VERSION = '0.20.0'
5
5
  end
data/my_api/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.7
1
+ 2.7.2
data/my_api/Gemfile CHANGED
@@ -6,6 +6,9 @@ gem 'jets'
6
6
 
7
7
  gem 'dynomite'
8
8
 
9
+ # See: https://github.com/boltops-tools/jets/issues/523
10
+ gem 'nokogiri', '~> 1.11.0'
11
+
9
12
  # development and test groups are not bundled as part of the deployment
10
13
  group :development, :test do
11
14
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
data/my_api/Gemfile.lock CHANGED
@@ -1,43 +1,44 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- actionmailer (6.0.3.4)
5
- actionpack (= 6.0.3.4)
6
- actionview (= 6.0.3.4)
7
- activejob (= 6.0.3.4)
4
+ actionmailer (6.1.2.1)
5
+ actionpack (= 6.1.2.1)
6
+ actionview (= 6.1.2.1)
7
+ activejob (= 6.1.2.1)
8
+ activesupport (= 6.1.2.1)
8
9
  mail (~> 2.5, >= 2.5.4)
9
10
  rails-dom-testing (~> 2.0)
10
- actionpack (6.0.3.4)
11
- actionview (= 6.0.3.4)
12
- activesupport (= 6.0.3.4)
13
- rack (~> 2.0, >= 2.0.8)
11
+ actionpack (6.1.2.1)
12
+ actionview (= 6.1.2.1)
13
+ activesupport (= 6.1.2.1)
14
+ rack (~> 2.0, >= 2.0.9)
14
15
  rack-test (>= 0.6.3)
15
16
  rails-dom-testing (~> 2.0)
16
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
- actionview (6.0.3.4)
18
- activesupport (= 6.0.3.4)
18
+ actionview (6.1.2.1)
19
+ activesupport (= 6.1.2.1)
19
20
  builder (~> 3.1)
20
21
  erubi (~> 1.4)
21
22
  rails-dom-testing (~> 2.0)
22
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
- activejob (6.0.3.4)
24
- activesupport (= 6.0.3.4)
24
+ activejob (6.1.2.1)
25
+ activesupport (= 6.1.2.1)
25
26
  globalid (>= 0.3.6)
26
- activemodel (6.0.3.4)
27
- activesupport (= 6.0.3.4)
28
- activerecord (6.0.3.4)
29
- activemodel (= 6.0.3.4)
30
- activesupport (= 6.0.3.4)
31
- activesupport (6.0.3.4)
27
+ activemodel (6.1.2.1)
28
+ activesupport (= 6.1.2.1)
29
+ activerecord (6.1.2.1)
30
+ activemodel (= 6.1.2.1)
31
+ activesupport (= 6.1.2.1)
32
+ activesupport (6.1.2.1)
32
33
  concurrent-ruby (~> 1.0, >= 1.0.2)
33
- i18n (>= 0.7, < 2)
34
- minitest (~> 5.1)
35
- tzinfo (~> 1.1)
36
- zeitwerk (~> 2.2, >= 2.2.2)
34
+ i18n (>= 1.6, < 2)
35
+ minitest (>= 5.1)
36
+ tzinfo (~> 2.0)
37
+ zeitwerk (~> 2.3)
37
38
  addressable (2.7.0)
38
39
  public_suffix (>= 2.0.2, < 5.0)
39
40
  aws-eventstream (1.1.0)
40
- aws-mfa-secure (0.4.2)
41
+ aws-mfa-secure (0.4.3)
41
42
  activesupport
42
43
  aws-sdk-core
43
44
  aws_config
@@ -45,8 +46,8 @@ GEM
45
46
  rainbow
46
47
  thor
47
48
  zeitwerk
48
- aws-partitions (1.402.0)
49
- aws-sdk-apigateway (1.56.0)
49
+ aws-partitions (1.416.0)
50
+ aws-sdk-apigateway (1.58.0)
50
51
  aws-sdk-core (~> 3, >= 3.109.0)
51
52
  aws-sigv4 (~> 1.1)
52
53
  aws-sdk-cloudformation (1.46.0)
@@ -55,7 +56,7 @@ GEM
55
56
  aws-sdk-cloudwatchlogs (1.38.0)
56
57
  aws-sdk-core (~> 3, >= 3.109.0)
57
58
  aws-sigv4 (~> 1.1)
58
- aws-sdk-core (3.109.3)
59
+ aws-sdk-core (3.111.0)
59
60
  aws-eventstream (~> 1, >= 1.0.2)
60
61
  aws-partitions (~> 1, >= 1.239.0)
61
62
  aws-sigv4 (~> 1.1)
@@ -66,23 +67,23 @@ GEM
66
67
  aws-sdk-kinesis (1.30.0)
67
68
  aws-sdk-core (~> 3, >= 3.109.0)
68
69
  aws-sigv4 (~> 1.1)
69
- aws-sdk-kms (1.39.0)
70
+ aws-sdk-kms (1.41.0)
70
71
  aws-sdk-core (~> 3, >= 3.109.0)
71
72
  aws-sigv4 (~> 1.1)
72
- aws-sdk-lambda (1.55.0)
73
+ aws-sdk-lambda (1.57.0)
73
74
  aws-sdk-core (~> 3, >= 3.109.0)
74
75
  aws-sigv4 (~> 1.1)
75
- aws-sdk-s3 (1.86.0)
76
+ aws-sdk-s3 (1.87.0)
76
77
  aws-sdk-core (~> 3, >= 3.109.0)
77
78
  aws-sdk-kms (~> 1)
78
79
  aws-sigv4 (~> 1.1)
79
80
  aws-sdk-sns (1.36.0)
80
81
  aws-sdk-core (~> 3, >= 3.109.0)
81
82
  aws-sigv4 (~> 1.1)
82
- aws-sdk-sqs (1.34.0)
83
+ aws-sdk-sqs (1.35.0)
83
84
  aws-sdk-core (~> 3, >= 3.109.0)
84
85
  aws-sigv4 (~> 1.1)
85
- aws-sdk-ssm (1.98.0)
86
+ aws-sdk-ssm (1.101.0)
86
87
  aws-sdk-core (~> 3, >= 3.109.0)
87
88
  aws-sigv4 (~> 1.1)
88
89
  aws-sigv4 (1.2.2)
@@ -90,20 +91,22 @@ GEM
90
91
  aws_config (0.1.0)
91
92
  builder (3.2.4)
92
93
  byebug (11.1.3)
93
- capybara (3.34.0)
94
+ capybara (3.35.3)
94
95
  addressable
95
96
  mini_mime (>= 0.1.3)
96
97
  nokogiri (~> 1.8)
97
98
  rack (>= 1.6.0)
98
99
  rack-test (>= 0.6.3)
99
- regexp_parser (~> 1.5)
100
+ regexp_parser (>= 1.5, < 3.0)
100
101
  xpath (~> 3.2)
102
+ cfn-status (0.4.2)
103
+ aws-sdk-cloudformation
101
104
  cfn_camelizer (0.4.9)
102
105
  activesupport
103
106
  memoist
104
107
  rainbow
105
- cfnresponse (0.4.0)
106
- concurrent-ruby (1.1.7)
108
+ cfn_response (0.2.0)
109
+ concurrent-ruby (1.1.8)
107
110
  crass (1.0.6)
108
111
  diff-lcs (1.4.4)
109
112
  dotenv (2.7.6)
@@ -116,14 +119,14 @@ GEM
116
119
  globalid (0.4.2)
117
120
  activesupport (>= 4.2.0)
118
121
  hashie (4.1.0)
119
- i18n (1.8.5)
122
+ i18n (1.8.8)
120
123
  concurrent-ruby (~> 1.0)
121
- jets (2.3.18)
122
- actionmailer (~> 6.0.0)
123
- actionpack (~> 6.0.0)
124
- actionview (~> 6.0.0)
125
- activerecord (~> 6.0.0)
126
- activesupport (~> 6.0.0)
124
+ jets (3.0.2)
125
+ actionmailer (~> 6.1.0)
126
+ actionpack (~> 6.1.0)
127
+ actionview (~> 6.1.0)
128
+ activerecord (~> 6.1.0)
129
+ activesupport (~> 6.1.0)
127
130
  aws-mfa-secure (~> 0.4.0)
128
131
  aws-sdk-apigateway
129
132
  aws-sdk-cloudformation
@@ -135,26 +138,25 @@ GEM
135
138
  aws-sdk-sns
136
139
  aws-sdk-sqs
137
140
  aws-sdk-ssm
141
+ cfn-status
138
142
  cfn_camelizer (~> 0.4.6)
139
- cfnresponse
143
+ cfn_response
140
144
  dotenv
141
145
  gems
142
146
  hashie
143
- jets-gems
144
147
  jets-html-sanitizer
145
148
  kramdown
146
149
  memoist
147
150
  mimemagic
148
151
  rack
149
- railties (~> 6.0.0)
152
+ railties (~> 6.1.0)
150
153
  rainbow
151
154
  recursive-open-struct
155
+ serverlessgems (~> 0.1.2)
152
156
  shotgun
153
157
  text-table
154
158
  thor
155
159
  zeitwerk
156
- jets-gems (0.2.2)
157
- gems
158
160
  jets-html-sanitizer (1.0.4)
159
161
  loofah (~> 2.2, >= 2.2.2)
160
162
  jmespath (1.4.0)
@@ -162,7 +164,7 @@ GEM
162
164
  rexml
163
165
  launchy (2.5.0)
164
166
  addressable (~> 2.7)
165
- loofah (2.8.0)
167
+ loofah (2.9.0)
166
168
  crass (~> 1.0.2)
167
169
  nokogiri (>= 1.5.9)
168
170
  mail (2.7.1)
@@ -172,13 +174,13 @@ GEM
172
174
  mimemagic (0.3.5)
173
175
  mini_mime (1.0.2)
174
176
  mini_portile2 (2.5.0)
175
- minitest (5.14.2)
176
- nio4r (2.5.4)
177
+ minitest (5.14.3)
178
+ nio4r (2.5.5)
177
179
  nokogiri (1.11.0)
178
180
  mini_portile2 (~> 2.5.0)
179
181
  racc (~> 1.4)
180
182
  public_suffix (4.0.6)
181
- puma (5.1.1)
183
+ puma (5.2.2)
182
184
  nio4r (~> 2.0)
183
185
  racc (1.5.2)
184
186
  rack (2.2.3)
@@ -189,16 +191,16 @@ GEM
189
191
  nokogiri (>= 1.6)
190
192
  rails-html-sanitizer (1.3.0)
191
193
  loofah (~> 2.3)
192
- railties (6.0.3.4)
193
- actionpack (= 6.0.3.4)
194
- activesupport (= 6.0.3.4)
194
+ railties (6.1.2.1)
195
+ actionpack (= 6.1.2.1)
196
+ activesupport (= 6.1.2.1)
195
197
  method_source
196
198
  rake (>= 0.8.7)
197
- thor (>= 0.20.3, < 2.0)
199
+ thor (~> 1.0)
198
200
  rainbow (3.0.0)
199
- rake (13.0.1)
201
+ rake (13.0.3)
200
202
  recursive-open-struct (1.1.3)
201
- regexp_parser (1.8.2)
203
+ regexp_parser (2.0.3)
202
204
  rexml (3.2.4)
203
205
  rspec (3.10.0)
204
206
  rspec-core (~> 3.10.0)
@@ -215,13 +217,16 @@ GEM
215
217
  rspec-support (3.10.0)
216
218
  rspec_junit_formatter (0.4.1)
217
219
  rspec-core (>= 2, < 4, != 2.12.0)
220
+ serverlessgems (0.1.2)
221
+ gems
222
+ memoist
223
+ zeitwerk
218
224
  shotgun (0.9.2)
219
225
  rack (>= 1.0)
220
226
  text-table (1.2.4)
221
- thor (1.0.1)
222
- thread_safe (0.3.6)
223
- tzinfo (1.2.8)
224
- thread_safe (~> 0.1)
227
+ thor (1.1.0)
228
+ tzinfo (2.0.4)
229
+ concurrent-ruby (~> 1.0)
225
230
  xpath (3.2.0)
226
231
  nokogiri (~> 1.8)
227
232
  zeitwerk (2.4.2)
@@ -235,6 +240,7 @@ DEPENDENCIES
235
240
  dynomite
236
241
  jets
237
242
  launchy
243
+ nokogiri (~> 1.11.0)
238
244
  puma
239
245
  rack
240
246
  rspec
@@ -50,7 +50,7 @@ class PaginationController < ApplicationController
50
50
  # but it should be `https://xxxxx.execute-api.ap-northeast-1.amazonaws.com/dev/pagination`.
51
51
  # So this is workaround.
52
52
  def page_link(page)
53
- query_strings = '?' + { page: page }.to_query
53
+ query_strings = "?#{{ page: page }.to_query}"
54
54
  uri = File.join(ENV['JETS_HOST'], ENV['JETS_STAGE'], pagination_path)
55
55
  uri.sub!('http://', 'https://')
56
56
  URI.join(uri, query_strings)
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'rubocop'
38
38
  spec.add_development_dependency 'rubocop-performance'
39
39
  spec.add_development_dependency 'rubocop-rspec'
40
- spec.add_development_dependency 'simplecov', '0.17.1'
40
+ spec.add_development_dependency 'simplecov', '0.21.2'
41
41
  spec.add_development_dependency 'webmock'
42
42
  spec.add_development_dependency 'yard'
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryz310
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-04 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - '='
186
186
  - !ruby/object:Gem::Version
187
- version: 0.17.1
187
+ version: 0.21.2
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - '='
193
193
  - !ruby/object:Gem::Version
194
- version: 0.17.1
194
+ version: 0.21.2
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: webmock
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -234,7 +234,6 @@ files:
234
234
  - ".gitignore"
235
235
  - ".rspec"
236
236
  - ".rubocop.yml"
237
- - ".rubocop_challenge.yml"
238
237
  - ".rubocop_todo.yml"
239
238
  - CHANGELOG.md
240
239
  - CODE_OF_CONDUCT.md
@@ -1 +0,0 @@
1
- ---