my_api_client 0.9.0 → 0.9.1

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: 38d80eab152ca28a8dbd5456ed21cbd85c123a8ae5a25183a7a843a97a7a0f9e
4
- data.tar.gz: ecf27feccc823ba7c45950b71ee5a8f7459bda3992ab81209c03eca957604e6f
3
+ metadata.gz: 8a388b02739580f3208f34dc4e56f852f028a6acf2fce08abb3d6689bb3809b3
4
+ data.tar.gz: cdce875732354336fef4208b48616c9380d8f698865a0fc9a7d893a6f36a2064
5
5
  SHA512:
6
- metadata.gz: e23a635d8a9342a536202d29dffe54d9bc2973e7e555f0d340a59862aad977bffd2501dad8af159c874cf56ca48b3ae0c6fe258d12584b81e96114d426bd9aa0
7
- data.tar.gz: '067183e46ad3421bb6d48c22c89201e2eaa9e490993264afb0a0500f136a0ef2abee5826b39f777902eb11c1c5bb61c93c66291f5c5d18480fd7bdc3289f3a36'
6
+ metadata.gz: b85475c4e54fe188d7669ad06bbaae159bfef53a89ddbbc6ec3132a8286b8b9e8564d421b7c7e024de2b5f09d888b3ed736c0a98b6f9d12bbaa99e837cd97e8c
7
+ data.tar.gz: a97decaa49de365e30c9ed0d2a99a9cc290de61f581be5219fd85cbc4931b6267ee5253d000a3c43e664df6e3056e1376708a9e51762ea0b37eb117ef2798be6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ## 0.9.1 (July 25, 2019)
4
+
5
+ ### Bugfix
6
+
7
+ * Fix/forbid nil option ([#97](https://github.com/ryz310/my_api_client/pull/97)) **Breaking Changes**
8
+
3
9
  ## 0.9.0 (July 25, 2019)
4
10
 
5
11
  ### New Features
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (0.9.0)
4
+ my_api_client (0.9.1)
5
5
  activesupport (>= 4.2.0)
6
6
  jsonpath
7
7
  sawyer (>= 0.8.2)
data/README.jp.md CHANGED
@@ -190,10 +190,10 @@ error_handling json: { '$.errors.code': :negative? }
190
190
  #### forbid_nil
191
191
 
192
192
  ```ruby
193
- error_handling status_code: 200, forbid_nil: true
193
+ error_handling status_code: 200, json: :forbid_nil
194
194
  ```
195
195
 
196
- 一部のサービスではサーバーから何らかの Response Body が返ってくる事を期待しているにも関わらず、空の結果が結果が返ってくるというケースがあるようです。こちらも実験的な機能ですが、そういったケースを検出するために `forbid_nil` オプションを用意しました。通常の場合、Response Body が空の場合はエラー判定をしませんが、このオプションに `true` を指定するとエラーとして検知する様になります。正常応答が空となる API も存在するので、誤検知にご注意下さい。
196
+ 一部のサービスではサーバーから何らかの Response Body が返ってくる事を期待しているにも関わらず、空の結果が結果が返ってくるというケースがあるようです。こちらも実験的な機能ですが、そういったケースを検出するために `json: :forbid_nil` オプションを用意しました。通常の場合、Response Body が空の場合はエラー判定をしませんが、このオプションを指定するとエラーとして検知する様になります。正常応答が空となる API も存在するので、誤検知にご注意下さい。
197
197
 
198
198
  #### MyApiClient::Params::Params
199
199
 
@@ -7,7 +7,7 @@ module MyApiClient
7
7
  # You need to define `class_attribute: error_handler, default: []` for the
8
8
  # included class.
9
9
  # @example
10
- # error_handling status_code: 200, forbid_nil: true
10
+ # error_handling status_code: 200, json: :forbid_nil
11
11
  # error_handling status_code: 400..499, raise: MyApiClient::ClientError
12
12
  # error_handling status_code: 500..599 do |params, logger|
13
13
  # logger.warn 'Server error occurred.'
@@ -28,10 +28,9 @@ module MyApiClient
28
28
  # Options for this generator
29
29
  # @option status_code [String, Range, Integer, Regexp]
30
30
  # Verifies response HTTP status code and raises error if matched
31
- # @option json [Hash]
32
- # Verifies response body as JSON and raises error if matched
33
- # @option forbid_nil [Boolean]
34
- # Verifies response_body and raises error if it is `nil`. default: false.
31
+ # @option json [Hash, Symbol]
32
+ # Verifies response body as JSON and raises error if matched.
33
+ # If specified `:forbid_nil`, it forbid `nil` on response_body.
35
34
  # @option with [Symbol]
36
35
  # Calls specified method when error detected
37
36
  # @option raise [MyApiClient::Error]
@@ -39,7 +38,6 @@ module MyApiClient
39
38
  # @yield [MyApiClient::Params::Params, MyApiClient::Logger]
40
39
  # Executes the block when error detected
41
40
  def error_handling(**options, &block)
42
- options[:forbid_nil] ||= false
43
41
  options[:raise] ||= MyApiClient::Error
44
42
  options[:block] = block if block_given?
45
43
 
@@ -12,10 +12,9 @@ module MyApiClient
12
12
  # The target of verifying
13
13
  # @option status_code [String, Range, Integer, Regexp]
14
14
  # Verifies response HTTP status code and raises error if matched
15
- # @option json [Hash]
16
- # Verifies response body as JSON and raises error if matched
17
- # @option forbid_nil [Boolean]
18
- # Verifies response_body and raises error if it is `nil`
15
+ # @option json [Hash, Symbol]
16
+ # Verifies response body as JSON and raises error if matched.
17
+ # If specified `:forbid_nil`, it forbid `nil` on response_body.
19
18
  # @option with [Symbol]
20
19
  # Calls specified method when error detected
21
20
  # @option raise [MyApiClient::Error]
@@ -32,7 +31,7 @@ module MyApiClient
32
31
 
33
32
  private
34
33
 
35
- attr_reader :_response, :_status_code, :_json, :_forbid_nil, :_with, :_raise, :_block
34
+ attr_reader :_response, :_status_code, :_json, :_with, :_raise, :_block
36
35
 
37
36
  def initialize(**options)
38
37
  options.each { |k, v| instance_variable_set("@_#{k}", v) }
@@ -72,7 +71,7 @@ module MyApiClient
72
71
 
73
72
  def match_all?(json, response_body)
74
73
  return true if json.nil?
75
- return true if response_body.nil? && _forbid_nil
74
+ return response_body.nil? if json == :forbid_nil
76
75
  return false if response_body.blank?
77
76
 
78
77
  json.all? do |path, operator|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyApiClient
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryz310