jsonapi.rb 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -4
- data/jsonapi.rb.gemspec +1 -1
- data/lib/jsonapi/active_model_error_serializer.rb +9 -3
- data/lib/jsonapi/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b1ee1a4a7cd79049959e65fed77c429414082d3
|
4
|
+
data.tar.gz: '0026897226e3074b5944b9ceac0dc4185ccb64d2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74be35a6b3eb14db777853c44b4cb0430e344f9dfb643a9e875fd05b1482b05708e8767aa9b8491ae05956c3492694e5c2a85d243848681c9f8e95c11e172b6d
|
7
|
+
data.tar.gz: 6b97c6e0e0b7bcebacf25a6895d4b24c5e079e41178d17601440cf341d22e7cba256c67132cc9ea65727859c257e95d5d7c89a1b5c2ca2b7d10dec9575591d5a
|
data/.travis.yml
CHANGED
@@ -3,5 +3,12 @@ sudo: false
|
|
3
3
|
language: ruby
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
|
6
|
+
- 2.6.1
|
7
|
+
- 2.3.7
|
8
|
+
env:
|
9
|
+
- RAILS_VERSION='~> 5'
|
10
|
+
- RAILS_VERSION='~> 4'
|
11
|
+
before_install:
|
12
|
+
- rm -f Gemfile.lock
|
13
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
14
|
+
- bundler || gem install bundler -v '< 2'
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -148,7 +148,7 @@ GEM
|
|
148
148
|
rspec-mocks (~> 3.8.0)
|
149
149
|
rspec-support (~> 3.8.0)
|
150
150
|
rspec-support (3.8.0)
|
151
|
-
rubocop (0.
|
151
|
+
rubocop (0.64.0)
|
152
152
|
jaro_winkler (~> 1.5.1)
|
153
153
|
parallel (~> 1.10)
|
154
154
|
parser (>= 2.5, != 2.5.1.1)
|
@@ -156,7 +156,7 @@ GEM
|
|
156
156
|
rainbow (>= 2.2.2, < 4.0)
|
157
157
|
ruby-progressbar (~> 1.7)
|
158
158
|
unicode-display_width (~> 1.4.0)
|
159
|
-
rubocop-rails_config (0.4.
|
159
|
+
rubocop-rails_config (0.4.3)
|
160
160
|
railties (>= 3.0)
|
161
161
|
rubocop (~> 0.58)
|
162
162
|
ruby-progressbar (1.10.0)
|
@@ -193,12 +193,12 @@ DEPENDENCIES
|
|
193
193
|
ffaker
|
194
194
|
jsonapi-rspec!
|
195
195
|
jsonapi.rb!
|
196
|
-
rails
|
196
|
+
rails (~> 5)
|
197
197
|
rspec (~> 3.0)
|
198
198
|
rspec-rails
|
199
199
|
rubocop-rails_config
|
200
200
|
simplecov
|
201
|
-
sqlite3
|
201
|
+
sqlite3 (~> 1.3.6)
|
202
202
|
yardstick
|
203
203
|
|
204
204
|
BUNDLED WITH
|
data/jsonapi.rb.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler'
|
29
29
|
spec.add_development_dependency 'rails'
|
30
|
-
spec.add_development_dependency 'sqlite3'
|
30
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3.6'
|
31
31
|
spec.add_development_dependency 'ffaker'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
spec.add_development_dependency 'rspec-rails'
|
@@ -16,8 +16,10 @@ module JSONAPI
|
|
16
16
|
|
17
17
|
attribute :code do |object|
|
18
18
|
_, error_hash = object
|
19
|
-
error_hash[:error]
|
20
|
-
|
19
|
+
code = error_hash[:error] unless error_hash[:error].is_a?(Hash)
|
20
|
+
code ||= error_hash[:message] || :invalid
|
21
|
+
# `parameterize` separator arguments are different on Rails 4 vs 5...
|
22
|
+
code.to_s.delete("''").parameterize.gsub('-', '_')
|
21
23
|
end
|
22
24
|
|
23
25
|
attribute :detail do |object, params|
|
@@ -25,7 +27,11 @@ module JSONAPI
|
|
25
27
|
errors_object = params[:model].errors
|
26
28
|
|
27
29
|
# Rails 4 provides just the message.
|
28
|
-
if error_hash[:error].present?
|
30
|
+
if error_hash[:error].present? && error_hash[:error].is_a?(Hash)
|
31
|
+
message = errors_object.generate_message(
|
32
|
+
error_key, nil, error_hash[:error]
|
33
|
+
)
|
34
|
+
elsif error_hash[:error].present?
|
29
35
|
message = errors_object.generate_message(error_key, error_hash[:error])
|
30
36
|
else
|
31
37
|
message = error_hash[:message]
|
data/lib/jsonapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas Suscov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_jsonapi
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.3.6
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.3.6
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: ffaker
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|