my_api_client 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gem_comet.yml +5 -0
- data/CHANGELOG.md +159 -0
- data/Gemfile.lock +2 -2
- data/README.jp.md +17 -0
- data/lib/my_api_client.rb +0 -17
- data/lib/my_api_client/error_handling.rb +6 -2
- data/lib/my_api_client/version.rb +1 -1
- data/my_api_client.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e548093a65be2816e7e86939b5570ce245af19b2422180cba0d9cff7f2f15ed
|
4
|
+
data.tar.gz: 0cbafd89253c574bc85cba334a6e90349b51af033aec2b8bcc5076cef22824d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b370c044f12d7d9862bbe3cb1d038a0f7a949acbf2390a442880d59db33f5f5d42ff73e8f205f4696ed2713b3102b86b6cc2a473e218ee2269ea385c6d80c890
|
7
|
+
data.tar.gz: e32efde0fd72efc444dbac9f5435cf9682fc5c18e4d0a8dc09571de9c4d29b8a36b375cee239a39cb05f4af65f2075cd245e6f985d01d11e4166ed0cc46b936f
|
data/.gem_comet.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# Change log
|
2
|
+
|
3
|
+
## 0.8.0 (July 23, 2019)
|
4
|
+
|
5
|
+
### New Features
|
6
|
+
|
7
|
+
* Allow method calling on error handling (#89)
|
8
|
+
|
9
|
+
### Breaking Changes
|
10
|
+
|
11
|
+
* Require sawyer gem v0.8.2 over (#88)
|
12
|
+
|
13
|
+
## 0.7.0 (July 17, 2019)
|
14
|
+
|
15
|
+
### Features
|
16
|
+
|
17
|
+
* Add request duration to metadata (#80)
|
18
|
+
* Support boolean on error handling (#81)
|
19
|
+
|
20
|
+
### Breaking Changes
|
21
|
+
|
22
|
+
* Modify the generator to be simple (#82)
|
23
|
+
|
24
|
+
### Misc
|
25
|
+
|
26
|
+
* Re-generate .rubocop_todo.yml with RuboCop v0.73.0 (#79)
|
27
|
+
* Introduce gem comet (#85)
|
28
|
+
|
29
|
+
## 0.6.2 (July 03, 2019)
|
30
|
+
|
31
|
+
### Bug fixes
|
32
|
+
|
33
|
+
* Fix logger setter on the template (#76)
|
34
|
+
* Fix #54
|
35
|
+
|
36
|
+
## 0.6.1 (July 03, 2019)
|
37
|
+
|
38
|
+
### Misc
|
39
|
+
|
40
|
+
* Bump yard from `0.9.19` to `0.9.20` (#72)
|
41
|
+
* Fix a security risk
|
42
|
+
|
43
|
+
## 0.6.0 (June 25, 2019)
|
44
|
+
|
45
|
+
### New Features
|
46
|
+
|
47
|
+
* New stubbing helper (#65)
|
48
|
+
|
49
|
+
```rb
|
50
|
+
stub_api_client_all(
|
51
|
+
ExampleApiClient,
|
52
|
+
get_user: { response: { id: 1 } }, # Returns an arbitrary response.
|
53
|
+
post_users: { id: 1 }, # You can ommit `response` keyword.
|
54
|
+
patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
|
55
|
+
delete_user: { raise: MyApiClient::ClientError } # Raises an arbitrary error.
|
56
|
+
)
|
57
|
+
response = ExampleApiClient.new.get_user(id: 123)
|
58
|
+
response.id # => 1
|
59
|
+
```
|
60
|
+
|
61
|
+
```rb
|
62
|
+
api_client = stub_api_client(
|
63
|
+
ExampleApiClient,
|
64
|
+
get_user: { response: { id: 1 } }, # Returns an arbitrary response.
|
65
|
+
post_users: { id: 1 }, # You can ommit `response` keyword.
|
66
|
+
patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
|
67
|
+
delete_user: { raise: MyApiClient::ClientError } # Raises an arbitrary error.
|
68
|
+
)
|
69
|
+
response = api_client.get_user(id: 123)
|
70
|
+
response.id # => 1
|
71
|
+
```
|
72
|
+
|
73
|
+
## 0.5.3 (June 23, 2019)
|
74
|
+
|
75
|
+
### Bug Fixes
|
76
|
+
|
77
|
+
* Initialize sawyer agent before logger initialization (#60)
|
78
|
+
* Fixes: The URL included in the logger is incomplete (#53)
|
79
|
+
* Fix parsing error if given text/html response (#61)
|
80
|
+
|
81
|
+
## 0.5.2 (June 23, 2019)
|
82
|
+
|
83
|
+
### Bug Fixes
|
84
|
+
|
85
|
+
* Fix the result of the retry (#57)
|
86
|
+
* Issue: Return values are nil after retrying (#56)
|
87
|
+
|
88
|
+
### Misc
|
89
|
+
|
90
|
+
* Improvement test coverage (#55)
|
91
|
+
|
92
|
+
## 0.5.1 (June 19, 2019)
|
93
|
+
|
94
|
+
### Bug Fixes
|
95
|
+
|
96
|
+
* Fix unsupported data for the Bugsnag breadcrumbs (#50)
|
97
|
+
|
98
|
+
## 0.5.0 (June 16, 2019)
|
99
|
+
|
100
|
+
### New Features
|
101
|
+
|
102
|
+
* Support bugsnag breadcrumb (#41)
|
103
|
+
|
104
|
+
### Misc
|
105
|
+
|
106
|
+
* Use CircleCI Orbs (#43)
|
107
|
+
|
108
|
+
## 0.4.0 (June 03, 2019)
|
109
|
+
|
110
|
+
### Feature
|
111
|
+
|
112
|
+
* Improvement for endpoint (#35)
|
113
|
+
|
114
|
+
### Bug Fix
|
115
|
+
|
116
|
+
* Add requirements for `$ bin/console` (#31)
|
117
|
+
|
118
|
+
### Misc
|
119
|
+
|
120
|
+
* Update RuboCop v0.70.0 -> v0.71.0 (#34)
|
121
|
+
|
122
|
+
## 0.3.0 (May 29, 2019)
|
123
|
+
|
124
|
+
### New Features
|
125
|
+
|
126
|
+
* Provide test helper for RSpec (#28)
|
127
|
+
|
128
|
+
## 0.2.0 (May 29, 2019)
|
129
|
+
|
130
|
+
### New Features
|
131
|
+
|
132
|
+
* Support Bugsnag metadata (#22)
|
133
|
+
|
134
|
+
### Misc
|
135
|
+
|
136
|
+
* Improve test coverage (#24)
|
137
|
+
* Fix problem on the release job (#25)
|
138
|
+
|
139
|
+
## 0.1.4 (May 28, 2019)
|
140
|
+
|
141
|
+
### Bugfix
|
142
|
+
|
143
|
+
* Support activesupport before v5.2.0 (#17)
|
144
|
+
|
145
|
+
## 0.1.3 (May 27, 2019)
|
146
|
+
|
147
|
+
* Fix wrong variable name (#13)
|
148
|
+
|
149
|
+
## 0.1.2 (May 27, 2019)
|
150
|
+
|
151
|
+
* Fix wrong method name (#10)
|
152
|
+
|
153
|
+
## 0.1.1 (May 27, 2019)
|
154
|
+
|
155
|
+
* Fix typo (#6)
|
156
|
+
|
157
|
+
## 0.1.0 (May 27, 2019)
|
158
|
+
|
159
|
+
* The first release :tada:
|
data/Gemfile.lock
CHANGED
data/README.jp.md
CHANGED
@@ -170,6 +170,23 @@ def my_error_handling(params, logger)
|
|
170
170
|
end
|
171
171
|
```
|
172
172
|
|
173
|
+
#### Symbol を利用する
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
error_handling json: { '$.errors.code': :negative? }
|
177
|
+
```
|
178
|
+
|
179
|
+
実験的な機能ですが、`status` や `json` の Value に `Symbol` を指定することで、結果値に対してメソッド呼び出しを行い、結果を判定させる事ができます。上記の場合、以下のような JSON にマッチします。なお、対象 Object に `#negative?` が存在しない場合はメソッドは呼び出されません。
|
180
|
+
|
181
|
+
```json
|
182
|
+
{
|
183
|
+
"erros": {
|
184
|
+
"code": -1,
|
185
|
+
"message": "Some error has occurred."
|
186
|
+
}
|
187
|
+
}
|
188
|
+
```
|
189
|
+
|
173
190
|
#### MyApiClient::Params::Params
|
174
191
|
|
175
192
|
WIP
|
data/lib/my_api_client.rb
CHANGED
@@ -25,20 +25,3 @@ begin
|
|
25
25
|
rescue LoadError
|
26
26
|
nil
|
27
27
|
end
|
28
|
-
|
29
|
-
if Sawyer::VERSION < '0.8.2'
|
30
|
-
module Sawyer
|
31
|
-
# NOTE: Old sawyer does not have attribute reader for response body.
|
32
|
-
# But new version sawyer is conflict some gems (e.g. octkit).
|
33
|
-
class Response
|
34
|
-
attr_reader :body, :env
|
35
|
-
|
36
|
-
alias _original_initialize initialize
|
37
|
-
|
38
|
-
def initialize(agent, res, options = {})
|
39
|
-
@body = res.body
|
40
|
-
_original_initialize(agent, res, options)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -45,20 +45,24 @@ module MyApiClient
|
|
45
45
|
|
46
46
|
private
|
47
47
|
|
48
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
48
49
|
def match?(operator, target)
|
49
|
-
return true if operator.nil?
|
50
|
-
|
51
50
|
case operator
|
51
|
+
when nil
|
52
|
+
true
|
52
53
|
when String, Integer, TrueClass, FalseClass
|
53
54
|
operator == target
|
54
55
|
when Range
|
55
56
|
operator.include?(target)
|
56
57
|
when Regexp
|
57
58
|
operator =~ target.to_s
|
59
|
+
when Symbol
|
60
|
+
target.respond_to?(operator) && target.public_send(operator)
|
58
61
|
else
|
59
62
|
raise "Unexpected operator type was given: #{operator.inspect}"
|
60
63
|
end
|
61
64
|
end
|
65
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
62
66
|
|
63
67
|
def match_all?(json, response_body)
|
64
68
|
return true if json.nil?
|
data/my_api_client.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency 'activesupport', '>= 4.2.0'
|
26
26
|
spec.add_dependency 'jsonpath'
|
27
|
-
spec.add_dependency 'sawyer'
|
27
|
+
spec.add_dependency 'sawyer', '>= 0.8.2'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
30
30
|
spec.add_development_dependency 'pry-byebug'
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryz310
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.8.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.8.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- ".rspec"
|
221
221
|
- ".rubocop.yml"
|
222
222
|
- ".rubocop_todo.yml"
|
223
|
+
- CHANGELOG.md
|
223
224
|
- CODE_OF_CONDUCT.md
|
224
225
|
- Gemfile
|
225
226
|
- Gemfile.lock
|