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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1557a7b02828b0aee6f7fafc9c67019e0486f05
4
- data.tar.gz: 23fd349bb61835beeab3d904d54c04715e4aa9ce
3
+ metadata.gz: 8b1ee1a4a7cd79049959e65fed77c429414082d3
4
+ data.tar.gz: '0026897226e3074b5944b9ceac0dc4185ccb64d2'
5
5
  SHA512:
6
- metadata.gz: 3d59d76a63b2bbc48f71cafe32f80f9ce5f3ed3575221619071799f76d8ed0bc648ba75988372df29a3aa6130d47a2c9b27375948f6ea165d54cd9e0eb53aaf8
7
- data.tar.gz: 9f735bea904696b5a3c043267827a0cadbfdcf8c3a65d42c817a241e139b4adb6a953b4506695a84d28d5c15cdd9cab726360cca1bf6f4e01419f1f10b57593f
6
+ metadata.gz: 74be35a6b3eb14db777853c44b4cb0430e344f9dfb643a9e875fd05b1482b05708e8767aa9b8491ae05956c3492694e5c2a85d243848681c9f8e95c11e172b6d
7
+ data.tar.gz: 6b97c6e0e0b7bcebacf25a6895d4b24c5e079e41178d17601440cf341d22e7cba256c67132cc9ea65727859c257e95d5d7c89a1b5c2ca2b7d10dec9575591d5a
@@ -3,5 +3,12 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.1
7
- before_install: gem install bundler
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
@@ -4,3 +4,4 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'jsonapi-rspec', github: 'stas/jsonapi-rspec'
7
+ gem 'rails', ENV['RAILS_VERSION']
@@ -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.63.1)
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.2)
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
@@ -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] || error_hash[:message]
20
- .to_s.delete("''").parameterize('_')
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]
@@ -1,3 +1,3 @@
1
1
  module JSONAPI
2
- VERSION = '1.4.1'
2
+ VERSION = '1.4.2'
3
3
  end
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.1
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-15 00:00:00.000000000 Z
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: '0'
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: '0'
96
+ version: 1.3.6
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: ffaker
99
99
  requirement: !ruby/object:Gem::Requirement