my_api_client 0.16.0 → 0.20.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.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +95 -135
  3. data/.gem_comet.yml +13 -2
  4. data/.rubocop.yml +5 -1
  5. data/.rubocop_todo.yml +39 -1
  6. data/CHANGELOG.md +142 -0
  7. data/Gemfile +0 -3
  8. data/Gemfile.lock +70 -64
  9. data/README.jp.md +126 -5
  10. data/bin/console +4 -0
  11. data/example/api_clients/application_api_client.rb +2 -2
  12. data/example/api_clients/my_rest_api_client.rb +9 -3
  13. data/gemfiles/{rails_4.2.gemfile → rails_6.1.gemfile} +1 -1
  14. data/lib/generators/rails/USAGE +1 -1
  15. data/lib/generators/rails/api_client_generator.rb +6 -0
  16. data/lib/generators/rails/templates/api_client.rb.erb +1 -1
  17. data/lib/generators/rspec/USAGE +1 -1
  18. data/lib/generators/rspec/api_client_generator.rb +6 -0
  19. data/lib/generators/rspec/templates/api_client_spec.rb.erb +23 -16
  20. data/lib/my_api_client/base.rb +2 -9
  21. data/lib/my_api_client/error_handling/generator.rb +0 -2
  22. data/lib/my_api_client/errors.rb +1 -0
  23. data/lib/my_api_client/integrations/bugsnag.rb +1 -1
  24. data/lib/my_api_client/params/params.rb +1 -3
  25. data/lib/my_api_client/request.rb +3 -3
  26. data/lib/my_api_client/request/basic.rb +1 -3
  27. data/lib/my_api_client/request/executor.rb +1 -1
  28. data/lib/my_api_client/rspec/matchers/request_to.rb +1 -1
  29. data/lib/my_api_client/rspec/stub.rb +30 -9
  30. data/lib/my_api_client/version.rb +1 -1
  31. data/my_api/.ruby-version +1 -1
  32. data/my_api/Gemfile +3 -0
  33. data/my_api/Gemfile.lock +116 -108
  34. data/my_api/app/controllers/pagination_controller.rb +2 -2
  35. data/my_api/spec/controllers/rest_controller_spec.rb +23 -5
  36. data/my_api_client.gemspec +3 -3
  37. data/rails_app/rails_5.2/.rspec +3 -0
  38. data/rails_app/rails_5.2/Gemfile +17 -0
  39. data/rails_app/rails_5.2/Gemfile.lock +174 -0
  40. data/rails_app/rails_5.2/README.md +24 -0
  41. data/rails_app/rails_5.2/Rakefile +8 -0
  42. data/rails_app/rails_5.2/app/controllers/application_controller.rb +4 -0
  43. data/rails_app/rails_5.2/app/jobs/application_job.rb +4 -0
  44. data/rails_app/rails_5.2/bin/bundle +5 -0
  45. data/rails_app/rails_5.2/bin/rails +6 -0
  46. data/rails_app/rails_5.2/bin/rake +6 -0
  47. data/rails_app/rails_5.2/bin/setup +27 -0
  48. data/rails_app/rails_5.2/bin/update +27 -0
  49. data/rails_app/rails_5.2/config.ru +7 -0
  50. data/rails_app/rails_5.2/config/application.rb +37 -0
  51. data/rails_app/rails_5.2/config/boot.rb +6 -0
  52. data/rails_app/rails_5.2/config/credentials.yml.enc +1 -0
  53. data/rails_app/rails_5.2/config/environment.rb +7 -0
  54. data/rails_app/rails_5.2/config/environments/development.rb +41 -0
  55. data/rails_app/rails_5.2/config/environments/production.rb +70 -0
  56. data/rails_app/rails_5.2/config/environments/test.rb +38 -0
  57. data/rails_app/rails_5.2/config/initializers/application_controller_renderer.rb +9 -0
  58. data/rails_app/rails_5.2/config/initializers/backtrace_silencers.rb +8 -0
  59. data/rails_app/rails_5.2/config/initializers/cors.rb +17 -0
  60. data/rails_app/rails_5.2/config/initializers/filter_parameter_logging.rb +6 -0
  61. data/rails_app/rails_5.2/config/initializers/inflections.rb +17 -0
  62. data/rails_app/rails_5.2/config/initializers/mime_types.rb +5 -0
  63. data/rails_app/rails_5.2/config/initializers/wrap_parameters.rb +11 -0
  64. data/rails_app/rails_5.2/config/locales/en.yml +33 -0
  65. data/rails_app/rails_5.2/config/routes.rb +5 -0
  66. data/rails_app/rails_5.2/config/spring.rb +8 -0
  67. data/rails_app/rails_5.2/public/robots.txt +1 -0
  68. data/rails_app/rails_5.2/spec/rails_helper.rb +14 -0
  69. data/rails_app/rails_5.2/spec/spec_helper.rb +13 -0
  70. data/rails_app/rails_6.0/.rspec +3 -0
  71. data/rails_app/rails_6.0/Gemfile +17 -0
  72. data/rails_app/rails_6.0/Gemfile.lock +190 -0
  73. data/rails_app/rails_6.0/README.md +24 -0
  74. data/rails_app/rails_6.0/Rakefile +8 -0
  75. data/rails_app/rails_6.0/app/controllers/application_controller.rb +4 -0
  76. data/rails_app/rails_6.0/app/jobs/application_job.rb +9 -0
  77. data/rails_app/rails_6.0/bin/rails +6 -0
  78. data/rails_app/rails_6.0/bin/rake +6 -0
  79. data/rails_app/rails_6.0/bin/setup +27 -0
  80. data/rails_app/rails_6.0/config.ru +7 -0
  81. data/rails_app/rails_6.0/config/application.rb +39 -0
  82. data/rails_app/rails_6.0/config/boot.rb +6 -0
  83. data/rails_app/rails_6.0/config/credentials.yml.enc +1 -0
  84. data/rails_app/rails_6.0/config/environment.rb +7 -0
  85. data/rails_app/rails_6.0/config/environments/development.rb +39 -0
  86. data/rails_app/rails_6.0/config/environments/production.rb +90 -0
  87. data/rails_app/rails_6.0/config/environments/test.rb +41 -0
  88. data/rails_app/rails_6.0/config/initializers/application_controller_renderer.rb +9 -0
  89. data/rails_app/rails_6.0/config/initializers/backtrace_silencers.rb +8 -0
  90. data/rails_app/rails_6.0/config/initializers/cors.rb +17 -0
  91. data/rails_app/rails_6.0/config/initializers/filter_parameter_logging.rb +6 -0
  92. data/rails_app/rails_6.0/config/initializers/inflections.rb +17 -0
  93. data/rails_app/rails_6.0/config/initializers/mime_types.rb +5 -0
  94. data/rails_app/rails_6.0/config/initializers/wrap_parameters.rb +11 -0
  95. data/rails_app/rails_6.0/config/locales/en.yml +33 -0
  96. data/rails_app/rails_6.0/config/routes.rb +5 -0
  97. data/rails_app/rails_6.0/config/spring.rb +8 -0
  98. data/rails_app/rails_6.0/public/robots.txt +1 -0
  99. data/rails_app/rails_6.0/spec/rails_helper.rb +14 -0
  100. data/rails_app/rails_6.0/spec/spec_helper.rb +13 -0
  101. data/rails_app/rails_6.1/.gitattributes +8 -0
  102. data/rails_app/rails_6.1/.gitignore +28 -0
  103. data/rails_app/rails_6.1/.rspec +3 -0
  104. data/rails_app/rails_6.1/Gemfile +17 -0
  105. data/rails_app/rails_6.1/Gemfile.lock +197 -0
  106. data/rails_app/rails_6.1/README.md +24 -0
  107. data/rails_app/rails_6.1/Rakefile +6 -0
  108. data/rails_app/rails_6.1/app/controllers/application_controller.rb +4 -0
  109. data/rails_app/rails_6.1/app/controllers/concerns/.keep +0 -0
  110. data/rails_app/rails_6.1/app/javascript/.keep +0 -0
  111. data/rails_app/rails_6.1/app/models/application_record.rb +5 -0
  112. data/rails_app/rails_6.1/app/models/concerns/.keep +0 -0
  113. data/rails_app/rails_6.1/bin/bundle +114 -0
  114. data/rails_app/rails_6.1/bin/rails +4 -0
  115. data/rails_app/rails_6.1/bin/rake +4 -0
  116. data/rails_app/rails_6.1/bin/setup +33 -0
  117. data/rails_app/rails_6.1/config.ru +6 -0
  118. data/rails_app/rails_6.1/config/application.rb +42 -0
  119. data/rails_app/rails_6.1/config/boot.rb +5 -0
  120. data/rails_app/rails_6.1/config/credentials.yml.enc +1 -0
  121. data/rails_app/rails_6.1/config/database.yml +25 -0
  122. data/rails_app/rails_6.1/config/environment.rb +7 -0
  123. data/rails_app/rails_6.1/config/environments/development.rb +59 -0
  124. data/rails_app/rails_6.1/config/environments/production.rb +97 -0
  125. data/rails_app/rails_6.1/config/environments/test.rb +51 -0
  126. data/rails_app/rails_6.1/config/initializers/application_controller_renderer.rb +9 -0
  127. data/rails_app/rails_6.1/config/initializers/backtrace_silencers.rb +10 -0
  128. data/rails_app/rails_6.1/config/initializers/cors.rb +17 -0
  129. data/rails_app/rails_6.1/config/initializers/filter_parameter_logging.rb +8 -0
  130. data/rails_app/rails_6.1/config/initializers/inflections.rb +17 -0
  131. data/rails_app/rails_6.1/config/initializers/mime_types.rb +5 -0
  132. data/rails_app/rails_6.1/config/initializers/wrap_parameters.rb +16 -0
  133. data/rails_app/rails_6.1/config/locales/en.yml +33 -0
  134. data/rails_app/rails_6.1/config/routes.rb +5 -0
  135. data/rails_app/rails_6.1/db/seeds.rb +8 -0
  136. data/rails_app/rails_6.1/lib/tasks/.keep +0 -0
  137. data/rails_app/rails_6.1/public/robots.txt +1 -0
  138. data/rails_app/rails_6.1/spec/rails_helper.rb +14 -0
  139. data/rails_app/rails_6.1/spec/spec_helper.rb +13 -0
  140. data/rails_app/rails_6.1/tmp/.keep +0 -0
  141. data/rails_app/rails_6.1/tmp/pids/.keep +0 -0
  142. data/rails_app/rails_6.1/vendor/.keep +0 -0
  143. metadata +115 -9
data/Gemfile CHANGED
@@ -4,9 +4,6 @@ source 'https://rubygems.org'
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
- # Workaound for ruby 2.4. Because activesupport v6.0.0 requires ruby 2.5 over.
8
- gem 'activesupport', '< 6.0.0'
9
-
10
7
  group :integrations, optional: true do
11
8
  gem 'bugsnag', '>= 6.11.0'
12
9
  end
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (0.16.0)
5
- activesupport (>= 4.2.0)
4
+ my_api_client (0.20.0)
5
+ activesupport (>= 5.2.0)
6
6
  faraday (>= 0.17.1)
7
7
  jsonpath
8
8
  sawyer (>= 0.8.2)
@@ -10,103 +10,109 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (5.2.4.2)
13
+ activesupport (6.1.3)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ zeitwerk (~> 2.3)
18
19
  addressable (2.7.0)
19
20
  public_suffix (>= 2.0.2, < 5.0)
20
- ast (2.4.0)
21
- bugsnag (6.13.0)
21
+ ast (2.4.2)
22
+ bugsnag (6.19.0)
22
23
  concurrent-ruby (~> 1.0)
23
- byebug (11.1.1)
24
- coderay (1.1.2)
25
- concurrent-ruby (1.1.6)
26
- crack (0.4.3)
27
- safe_yaml (~> 1.0.0)
28
- diff-lcs (1.3)
29
- docile (1.3.2)
30
- faraday (1.0.0)
24
+ byebug (11.1.3)
25
+ coderay (1.1.3)
26
+ concurrent-ruby (1.1.8)
27
+ crack (0.4.5)
28
+ rexml
29
+ diff-lcs (1.4.4)
30
+ docile (1.3.5)
31
+ faraday (1.3.0)
32
+ faraday-net_http (~> 1.0)
31
33
  multipart-post (>= 1.2, < 3)
34
+ ruby2_keywords
35
+ faraday-net_http (1.0.1)
32
36
  hashdiff (1.0.1)
33
- i18n (1.8.2)
37
+ i18n (1.8.9)
34
38
  concurrent-ruby (~> 1.0)
35
- jaro_winkler (1.5.4)
36
- json (2.3.0)
37
- jsonpath (1.0.5)
39
+ jsonpath (1.1.0)
38
40
  multi_json
39
- to_regexp (~> 0.2.1)
40
41
  method_source (1.0.0)
41
- minitest (5.14.0)
42
- multi_json (1.14.1)
42
+ minitest (5.14.4)
43
+ multi_json (1.15.0)
43
44
  multipart-post (2.1.1)
44
- parallel (1.19.1)
45
- parser (2.7.0.5)
46
- ast (~> 2.4.0)
47
- pry (0.13.0)
45
+ parallel (1.20.1)
46
+ parser (3.0.0.0)
47
+ ast (~> 2.4.1)
48
+ pry (0.13.1)
48
49
  coderay (~> 1.1)
49
50
  method_source (~> 1.0)
50
51
  pry-byebug (3.9.0)
51
52
  byebug (~> 11.0)
52
53
  pry (~> 0.13.0)
53
- public_suffix (4.0.3)
54
+ public_suffix (4.0.6)
54
55
  rainbow (3.0.0)
55
- rake (13.0.1)
56
+ rake (13.0.3)
57
+ regexp_parser (2.1.1)
56
58
  rexml (3.2.4)
57
- rspec (3.9.0)
58
- rspec-core (~> 3.9.0)
59
- rspec-expectations (~> 3.9.0)
60
- rspec-mocks (~> 3.9.0)
61
- rspec-core (3.9.1)
62
- rspec-support (~> 3.9.1)
63
- rspec-expectations (3.9.1)
59
+ rspec (3.10.0)
60
+ rspec-core (~> 3.10.0)
61
+ rspec-expectations (~> 3.10.0)
62
+ rspec-mocks (~> 3.10.0)
63
+ rspec-core (3.10.1)
64
+ rspec-support (~> 3.10.0)
65
+ rspec-expectations (3.10.1)
64
66
  diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.9.0)
66
- rspec-mocks (3.9.1)
67
+ rspec-support (~> 3.10.0)
68
+ rspec-mocks (3.10.2)
67
69
  diff-lcs (>= 1.2.0, < 2.0)
68
- rspec-support (~> 3.9.0)
69
- rspec-support (3.9.2)
70
+ rspec-support (~> 3.10.0)
71
+ rspec-support (3.10.2)
70
72
  rspec_junit_formatter (0.4.1)
71
73
  rspec-core (>= 2, < 4, != 2.12.0)
72
- rubocop (0.80.1)
73
- jaro_winkler (~> 1.5.1)
74
+ rubocop (1.11.0)
74
75
  parallel (~> 1.10)
75
- parser (>= 2.7.0.1)
76
+ parser (>= 3.0.0.0)
76
77
  rainbow (>= 2.2.2, < 4.0)
78
+ regexp_parser (>= 1.8, < 3.0)
77
79
  rexml
80
+ rubocop-ast (>= 1.2.0, < 2.0)
78
81
  ruby-progressbar (~> 1.7)
79
- unicode-display_width (>= 1.4.0, < 1.7)
80
- rubocop-performance (1.5.2)
81
- rubocop (>= 0.71.0)
82
- rubocop-rspec (1.38.1)
83
- rubocop (>= 0.68.1)
84
- ruby-progressbar (1.10.1)
85
- safe_yaml (1.0.5)
82
+ unicode-display_width (>= 1.4.0, < 3.0)
83
+ rubocop-ast (1.4.1)
84
+ parser (>= 2.7.1.5)
85
+ rubocop-performance (1.10.1)
86
+ rubocop (>= 0.90.0, < 2.0)
87
+ rubocop-ast (>= 0.4.0)
88
+ rubocop-rspec (2.2.0)
89
+ rubocop (~> 1.0)
90
+ rubocop-ast (>= 1.1.0)
91
+ ruby-progressbar (1.11.0)
92
+ ruby2_keywords (0.0.4)
86
93
  sawyer (0.8.2)
87
94
  addressable (>= 2.3.5)
88
95
  faraday (> 0.8, < 2.0)
89
- simplecov (0.17.1)
96
+ simplecov (0.21.2)
90
97
  docile (~> 1.1)
91
- json (>= 1.8, < 3)
92
- simplecov-html (~> 0.10.0)
93
- simplecov-html (0.10.2)
94
- thread_safe (0.3.6)
95
- to_regexp (0.2.1)
96
- tzinfo (1.2.6)
97
- thread_safe (~> 0.1)
98
- unicode-display_width (1.6.1)
99
- webmock (3.8.3)
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
+ tzinfo (2.0.4)
103
+ concurrent-ruby (~> 1.0)
104
+ unicode-display_width (2.0.0)
105
+ webmock (3.12.1)
100
106
  addressable (>= 2.3.6)
101
107
  crack (>= 0.3.2)
102
108
  hashdiff (>= 0.4.0, < 2.0.0)
103
- yard (0.9.24)
109
+ yard (0.9.26)
110
+ zeitwerk (2.4.2)
104
111
 
105
112
  PLATFORMS
106
113
  ruby
107
114
 
108
115
  DEPENDENCIES
109
- activesupport (< 6.0.0)
110
116
  bugsnag (>= 6.11.0)
111
117
  bundler (>= 2.0)
112
118
  my_api_client!
@@ -117,9 +123,9 @@ DEPENDENCIES
117
123
  rubocop
118
124
  rubocop-performance
119
125
  rubocop-rspec
120
- simplecov (= 0.17.1)
126
+ simplecov (= 0.21.2)
121
127
  webmock
122
128
  yard
123
129
 
124
130
  BUNDLED WITH
125
- 2.1.2
131
+ 2.2.3
data/README.jp.md CHANGED
@@ -12,8 +12,8 @@ MyApiClient は API リクエストクラスを作成するための汎用的な
12
12
 
13
13
  ## Supported Versions
14
14
 
15
- * Ruby 2.4, 2.5, 2.6, 2.7
16
- * Rails 4.2, 5.0, 5.1, 5.2, 6.0
15
+ * Ruby 2.5, 2.6, 2.7, 3.0
16
+ * Rails 5.2, 6.0, 6.1
17
17
 
18
18
  ## Installation
19
19
 
@@ -26,7 +26,7 @@ gem 'my_api_client'
26
26
  Ruby on Rails を利用している場合は `generator` 機能を利用できます。
27
27
 
28
28
  ```sh
29
- $ rails g api_client path/to/resource get:path/to/resource
29
+ $ rails g api_client path/to/resource get:path/to/resource --endpoint https://example.com
30
30
 
31
31
  create app/api_clients/application_api_client.rb
32
32
  create app/api_clients/path/to/resource_api_client.rb
@@ -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,120 @@ 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
+
706
+ ## Deployment
707
+
708
+ この gem のリリースには [gem_comet](https://github.com/ryz310/gem_comet) を利用しています。
709
+ `gem_comet` の README.md にも使い方が載っていますが、備忘録のため、こちらにもリリースフローを記載しておきます。
710
+
711
+ ### Preparement
712
+
713
+ 以下のコマンドで `.envrc` を作成し、 `GITHUB_ACCESS_TOKEN` を設定します。
714
+
715
+ ```sh
716
+ $ cp .envrc.skeleton .envrc
717
+ ```
718
+
719
+ 以下のコマンドで `gem_comet` をインストールします。
720
+
721
+ ```sh
722
+ $ gem install gem_comet
723
+ ```
724
+
725
+ ### USAGE
726
+
727
+ 以下のコマンドで、最後のリリースから現在までに merge した PR の一覧を確認できます。
728
+
729
+ ```sh
730
+ $ gem_comet changelog
731
+ ```
732
+
733
+ 以下のコマンドで gem のリリースを実行します。
734
+ `{VERSION}` には新しく付与するバージョン番号を指定します。
735
+
736
+ ```sh
737
+ $ gem_comet release {VERSION}
738
+ ```
739
+
740
+ 実行すると、 https://github.com/ryz310/my_api_client/pulls に以下のような PR が作成されます。
741
+
742
+ * [Update v0\.16\.1](https://github.com/ryz310/my_api_client/pull/297)
743
+ * [Release v0\.16\.1](https://github.com/ryz310/my_api_client/pull/298)
744
+
745
+ まず、 `Update v{VERSION}` という PR から merge に取り掛かります。
746
+
747
+ PR のコメントにも TODO が記載されていますが、まず、バージョン番号が正しく採番されているかを確認します。
748
+
749
+ See: [314a4c0](https://github.com/ryz310/my_api_client/pull/297/commits/314a4c06f66324ce77b640b1ee8db5c84ee038a2)
750
+
751
+ 次に `CHANGELOG.md` を編集して、 CHANGELOG を見やすく整理します。
752
+
753
+ See: [33a2d17](https://github.com/ryz310/my_api_client/pull/297/commits/33a2d1703c773813c837e74ee3181906b2f2e502)
754
+
755
+ これらが整ったら、 `Update v{VERSION}` を merge します。
756
+
757
+ これでリリース準備が整ったので、`Release v{VERSION}` の merge に取り掛かります。
758
+
759
+ この PR にこれからリリースする gem に対する変更が全て載っています。
760
+ 変更内容の最終確認をして、 CI も通ったことを確認したら `Release v{VERSION}` を merge します。
761
+
762
+ あとは Circle CI 側で gem のリリースが自動実行されるので、暫く待ちましょう。
763
+
764
+ お疲れさまでした :tea:
765
+
645
766
  ## Contributing
646
767
 
647
768
  不具合の報告や Pull Request を歓迎しています。OSS という事で自分はなるべく頑張って英語を使うようにしていますが、日本語での報告でも大丈夫です :+1:
data/bin/console CHANGED
@@ -3,6 +3,10 @@
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'my_api_client'
6
+ require './example/api_clients/my_error_api_client'
7
+ require './example/api_clients/my_rest_api_client'
8
+ require './example/api_clients/my_pagination_api_client'
9
+ require './example/api_clients/my_status_api_client'
6
10
 
7
11
  # You can add fixtures and/or initialization code here to make experimenting
8
12
  # with your gem easier. You can also use a different console, if you like.
@@ -8,6 +8,6 @@ class ApplicationApiClient < MyApiClient::Base
8
8
 
9
9
  self.logger = ::Logger.new(nil)
10
10
 
11
- http_open_timeout 2.seconds
12
- http_read_timeout 3.seconds
11
+ http_open_timeout 5.seconds
12
+ http_read_timeout 5.seconds
13
13
  end
@@ -18,13 +18,19 @@ class MyRestApiClient < ApplicationApiClient
18
18
  end
19
19
 
20
20
  # POST rest
21
- def create_post(title:)
21
+ def post_post(title:)
22
22
  body = { title: title }
23
23
  post 'rest', body: body, headers: headers
24
24
  end
25
25
 
26
- # POST/PUT/PATCH rest/:id
27
- def update_post(id:, title:)
26
+ # PUT rest/:id
27
+ def put_post(id:, title:)
28
+ body = { title: title }
29
+ put "rest/#{id}", body: body, headers: headers
30
+ end
31
+
32
+ # PATCH rest/:id
33
+ def patch_post(id:, title:)
28
34
  body = { title: title }
29
35
  patch "rest/#{id}", body: body, headers: headers
30
36
  end
@@ -6,7 +6,7 @@ source 'https://rubygems.org'
6
6
 
7
7
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
 
9
- gem 'activesupport', '~> 4.2.0'
9
+ gem 'activesupport', '~> 6.1.0'
10
10
 
11
11
  group :integrations, optional: true do
12
12
  gem 'bugsnag', '>= 6.11.0'
@@ -2,7 +2,7 @@ Description:
2
2
  Generate a new api client class files.
3
3
 
4
4
  Example:
5
- `rails g api_client path/to/resource get:path/to/resource`
5
+ `rails g api_client path/to/resource get:path/to/resource` --endpoint https://example.com
6
6
 
7
7
  This will create:
8
8
  create app/api_clients/application_api_client.rb
@@ -15,6 +15,12 @@ module Rails
15
15
  default: %w[get:path/to/resource post:path/to/resource],
16
16
  banner: '{method}:{path} {method}:{path}'
17
17
 
18
+ class_option :endpoint,
19
+ type: :string,
20
+ default: 'https://example.com',
21
+ banner: 'https://example.com',
22
+ desc: 'Common part of the target API endpoint'
23
+
18
24
  def generate_root_class
19
25
  file_path = File.join('app/api_clients', 'application_api_client.rb')
20
26
  return if File.exist?(file_path)