fulfil-io 0.4.1 → 0.4.2

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: c4ad2709b85c238ad07608d510455eb6af65bbfb2b7bf1fe7a43bd42ec3327e8
4
- data.tar.gz: 76d7e6189a7cc118eab1a3d4db1d10f7450a2ac96df50be1334abec7b877da7e
3
+ metadata.gz: 35c4c9a9a5c6e89dc1963296ecb2d2bef838a93fe67f4d16b2cc6d1234870787
4
+ data.tar.gz: 54030ba2a9cffd08d0f720a195cb29196a8bc38d6860fc7ff30e59b3328f97a9
5
5
  SHA512:
6
- metadata.gz: 0b25ab906e005e6655a66db79f52a0edd4404a06a7a1ff1c90fea03eeb1e00e18c0e8a823e11ce45a2cf8a65ceb7c356882649d1cc3a586bc429eaedc1ec42f7
7
- data.tar.gz: e7e965321b2e3aba9abd61add0c22dab1e81cc3ea3809f23ca164dcc46930ade6083bf3de243a23d53fae90b8bf08849041af40a808d41f1c27f1f750b575b32
6
+ metadata.gz: 1b73ec09fc10b8183ed80d0f60bfe8911394c8d8e624a28e8d4aa77889a2912673876faf5af204ada89ba87ee9fff32796fb8b43a2b6825c1eb91eaf3773fb47
7
+ data.tar.gz: a0251fe789efa3744c331e5b590f64a0ce6dd100b204e0413b98d925733c99fda0be8ba2d5e8fb7e7fc2793a1f26b25030b58bdab61ee69bf3b68c59154c9582
@@ -1,3 +1,9 @@
1
+ ## 0.4.2
2
+
3
+ * Raise an `UnhandledTypeError` and reveal the offender.
4
+ * Convert timedelta data types to Decimals.
5
+ * Don't use `.present?` to check if response is a Hash.
6
+
1
7
  ## 0.4.1
2
8
 
3
9
  * @cdmwebs screwed up the release process, so this is a tiny bump to fix. No code changes.
@@ -76,7 +76,7 @@ module Fulfil
76
76
  private
77
77
 
78
78
  def parse(result: nil, results: [])
79
- if result.present?
79
+ if result
80
80
  parse_single(result: result)
81
81
  else
82
82
  parse_multiple(results: results)
@@ -1,5 +1,14 @@
1
1
  module Fulfil
2
2
  module ResponseParser
3
+ class UnhandledTypeError < StandardError
4
+ attr_reader :value
5
+
6
+ def initialize(msg, value)
7
+ @value = value
8
+ super(msg)
9
+ end
10
+ end
11
+
3
12
  # Handle value objects, for example:
4
13
  #
5
14
  # "order_date": {
@@ -19,10 +28,13 @@ module Fulfil
19
28
  when 'datetime'
20
29
  time = value.dig('iso_string')
21
30
  DateTime.parse(time)
22
- when 'Decimal'
31
+ when 'Decimal', 'timedelta'
23
32
  value.dig('decimal').to_f
24
33
  else
25
- raise UnhandledTypeError, value
34
+ raise UnhandledTypeError.new(
35
+ "received a value that we don't know how to handle: #{json_class}",
36
+ json_class
37
+ )
26
38
  end
27
39
  end
28
40
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fulfil
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fulfil-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Moore