acfs 1.5.0 → 1.5.1

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: 53acc88297d3217a5d01db2ce713f935835b05438471fd2b69918029b5480954
4
- data.tar.gz: d61a2f4e5014dab37d4e1a857d548df8dfb42afcaba219005556f203ea68da65
3
+ metadata.gz: 55e1388e9df4207138b2a54f1e9d56c349ac407e52364b849887e9682abfee7e
4
+ data.tar.gz: ccf1b3550de8f5222988333d14e480ec07742fb0398d3adfb9504be4ca4168b4
5
5
  SHA512:
6
- metadata.gz: 35f66d3569256b183cb7c78fed7c41f0ce916f41ec081e60696693af8b869d47e797a53474942c4847cefb621e58d3d52ddf629168c63b7b2d558d1db23cf74a
7
- data.tar.gz: 5e03be0b16cb469061b55a3c4467a4fa71496925caa086ed5d024ed79aaefdcc568afd970d526c284b08b8db06593f51886d8642f035f78f2ed7f89bd1b8f311
6
+ metadata.gz: d34c6fd3d4e83e22757633efc72c8d399778b86665f4b5bb6fb46c8d4f93782f996fe307904ac83f9b16701157ecb8418977466cad9d9c5a78c6ea1074e9ddd7
7
+ data.tar.gz: 3460436cd3a9d61241155658e4c46ef556b69d00fd389aca73c78ca6484b29bac9b3c45a0fd310b41259aba68f8aad55c7ca95a259e18075c2d88b2515bacd52
@@ -14,6 +14,13 @@
14
14
  ### Breaks
15
15
 
16
16
 
17
+ ## 1.5.1 - (2020-12-30)
18
+ ---
19
+
20
+ ### Changes
21
+ * Revert back to using `::MultiJson`
22
+
23
+
17
24
  ## 1.5.0 - (2020-06-19)
18
25
  ---
19
26
 
@@ -28,15 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency 'actionpack', '>= 5.2'
29
29
  spec.add_runtime_dependency 'activemodel', '>= 5.2'
30
30
  spec.add_runtime_dependency 'activesupport', '>= 5.2'
31
+ spec.add_runtime_dependency 'multi_json', '~> 1.0'
31
32
  spec.add_runtime_dependency 'rack'
32
33
  spec.add_runtime_dependency 'typhoeus', '~> 1.0'
33
34
 
34
35
  spec.add_development_dependency 'bundler'
35
-
36
- if ENV['TRAVIS_BUILD_NUMBER'] && !ENV['TRAVIS_TAG']
37
- # Append travis build number for auto-releases
38
- # rubocop:disable Gemspec/DuplicatedAssignment
39
- spec.version = "#{spec.version}.1.b#{ENV['TRAVIS_BUILD_NUMBER']}"
40
- # rubocop:enable Gemspec/DuplicatedAssignment
41
- end
42
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
3
+ require 'multi_json'
4
4
 
5
5
  module Acfs
6
6
  module Middleware
@@ -12,11 +12,13 @@ module Acfs
12
12
  end
13
13
 
14
14
  def encode(data)
15
- ::JSON.dump data
15
+ ::MultiJson.dump(data)
16
16
  end
17
17
 
18
18
  def decode(body)
19
- ::JSON.load body
19
+ ::MultiJson.load(body)
20
+ rescue ::MultiJson::ParseError => e
21
+ raise ::JSON::ParserError.new(e)
20
22
  end
21
23
  end
22
24
 
@@ -244,9 +244,9 @@ class Acfs::Resource
244
244
  @local_attributes ||= {}
245
245
  end
246
246
 
247
- def define_attribute(name, type, opts = {})
247
+ def define_attribute(name, type, **opts)
248
248
  name = name.to_s
249
- attribute = type.new opts
249
+ attribute = type.new(**opts)
250
250
 
251
251
  local_attributes[name] = attribute
252
252
  define_attribute_method name
@@ -22,7 +22,7 @@ module Acfs::Resource::Attributes
22
22
  def cast_value(value)
23
23
  if value.blank?
24
24
  nil
25
- elsif value.acts_like?(:time) || value.acts_like?(:date)
25
+ elsif !value.is_a?(::String) && value.respond_to?(:to_datetime)
26
26
  value.to_datetime
27
27
  else
28
28
  ::DateTime.iso8601 value
@@ -2,12 +2,6 @@
2
2
 
3
3
  class Acfs::Resource
4
4
  module Validation
5
- def valid?(*args)
6
- super
7
- remote_errors.each {|f, e| errors.add f, e }
8
- errors.empty?
9
- end
10
-
11
5
  def remote_errors
12
6
  @remote_errors ||= ActiveModel::Errors.new self
13
7
  end
@@ -35,5 +29,21 @@ class Acfs::Resource
35
29
 
36
30
  super
37
31
  end
32
+
33
+ if ::ActiveModel.version >= Gem::Version.new('6.1')
34
+ def valid?(*args)
35
+ super
36
+
37
+ remote_errors.each {|e| errors.add(e.attribute, e.message) }
38
+ errors.empty?
39
+ end
40
+ else
41
+ def valid?(*args)
42
+ super
43
+
44
+ remote_errors.each {|f, e| errors.add(f, e) }
45
+ errors.empty?
46
+ end
47
+ end
38
48
  end
39
49
  end
@@ -4,7 +4,7 @@ module Acfs
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 5
7
- PATCH = 0
7
+ PATCH = 1
8
8
  STAGE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
@@ -28,6 +28,20 @@ describe Acfs::Middleware::JSON do
28
28
  expect(JSON.parse(request.body)).to eq data.map(&:stringify_keys)
29
29
  end
30
30
  end
31
+
32
+ context 'with #to_json objects' do
33
+ let(:data) do
34
+ Class.new do
35
+ def to_json(*)
36
+ '{"a": 1, "b": 2}'
37
+ end
38
+ end.new
39
+ end
40
+
41
+ it 'should serialize data with #to_json' do
42
+ expect(JSON.parse(request.body)).to eq 'a' => 1, 'b' => 2
43
+ end
44
+ end
31
45
  end
32
46
 
33
47
  describe 'decode' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: multi_json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rack
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
228
  - !ruby/object:Gem::Version
215
229
  version: '0'
216
230
  requirements: []
217
- rubygems_version: 3.1.2
231
+ rubygems_version: 3.2.3
218
232
  signing_key:
219
233
  specification_version: 4
220
234
  summary: An abstract API base client for service oriented application.