json_api_responders 2.4.0 → 2.7.0

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: 7df311b93bbca363d13105a1db7d3d3edad5f2739f5b4c59fa9e9ba55cf917c5
4
- data.tar.gz: 1f7eb04edff138ccfdf2a0cfab648c2236200665124b1a9d4e875a28a53ebc64
3
+ metadata.gz: ecf51675d2f2b3e3a6208800ec9f29aa601e2ebf31b33eea1127d925e6a2cb86
4
+ data.tar.gz: 69dd03066147c3beb5435c7aaa0357f41f89a69624da832a81857a7d5bda659e
5
5
  SHA512:
6
- metadata.gz: '09e3590a12b0578c798796c5bfe35351d5282cb6159034e3127b4f9c163d04393417fe4da194526a3ec78f3e7aa8d7d0fe44436583125588db017730b6f87349'
7
- data.tar.gz: 591341c5b4585cdc55ae6646fd7b8698bb42812cb9e1a0fcfd3eb9ff4f1b70fbdb88b1c20ef7e7a428c130684aebfdb57ffd55e07f72cb34aeba3fa82730d42b
6
+ metadata.gz: 1d634452083be4d39a5353ee67afcda0071bd7df540a1c86446e52ed96a342f4a9c07ed2c0805c32165fee226fa3a5ffcfd289ba5bceb825e6d209ce6084d088
7
+ data.tar.gz: a53084be6c3a5b50c0baaa43630bf0fea0fea2483c6baddc38a3165c13dc90928bae975a3e1ee8789da27d1d332ffeeee40e8261216ebad4bee75ff0f0540502
@@ -0,0 +1,24 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ name: Ruby ${{ matrix.ruby }}
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby: [2.7, '3.0', 3.1]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ bundler-cache: true
23
+ - name: Run tests
24
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ json_api_responders (2.7.0)
5
+ activemodel
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (7.0.3)
11
+ activesupport (= 7.0.3)
12
+ activesupport (7.0.3)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ byebug (11.1.3)
18
+ codeclimate-test-reporter (1.0.9)
19
+ simplecov (<= 0.13)
20
+ coderay (1.1.3)
21
+ concurrent-ruby (1.1.10)
22
+ diff-lcs (1.5.0)
23
+ docile (1.1.5)
24
+ i18n (1.10.0)
25
+ concurrent-ruby (~> 1.0)
26
+ json (2.6.1)
27
+ method_source (1.0.0)
28
+ minitest (5.15.0)
29
+ pry (0.13.1)
30
+ coderay (~> 1.1)
31
+ method_source (~> 1.0)
32
+ pry-byebug (3.9.0)
33
+ byebug (~> 11.0)
34
+ pry (~> 0.13.0)
35
+ rack (2.2.3)
36
+ rake (10.5.0)
37
+ rspec (3.11.0)
38
+ rspec-core (~> 3.11.0)
39
+ rspec-expectations (~> 3.11.0)
40
+ rspec-mocks (~> 3.11.0)
41
+ rspec-core (3.11.0)
42
+ rspec-support (~> 3.11.0)
43
+ rspec-expectations (3.11.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.11.0)
46
+ rspec-mocks (3.11.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.11.0)
49
+ rspec-support (3.11.0)
50
+ simplecov (0.13.0)
51
+ docile (~> 1.1.0)
52
+ json (>= 1.8, < 3)
53
+ simplecov-html (~> 0.10.0)
54
+ simplecov-html (0.10.2)
55
+ tzinfo (2.0.4)
56
+ concurrent-ruby (~> 1.0)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ bundler
63
+ codeclimate-test-reporter
64
+ json_api_responders!
65
+ pry-byebug
66
+ rack
67
+ rake (~> 10.0)
68
+ rspec
69
+ simplecov
70
+
71
+ BUNDLED WITH
72
+ 2.3.13
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ['lib']
28
28
 
29
- spec.add_development_dependency 'bundler', '~> 1.11'
29
+ spec.add_development_dependency 'bundler'
30
30
  spec.add_development_dependency 'rake', '~> 10.0'
31
31
  # spec.add_development_dependency 'rspec-rails'
32
32
  spec.add_development_dependency 'rspec'
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'pry-byebug'
35
35
  spec.add_development_dependency 'simplecov'
36
36
  spec.add_development_dependency 'codeclimate-test-reporter'
37
+ spec.add_dependency 'activemodel'
37
38
  end
@@ -35,7 +35,7 @@ module JsonApiResponders
35
35
 
36
36
  def respond_to_destroy_action
37
37
  self.status ||= :no_content
38
- controller.head(status, render_options)
38
+ controller.head(status, **render_options)
39
39
  end
40
40
 
41
41
  def render_resource
@@ -37,7 +37,7 @@ module JsonApiResponders
37
37
 
38
38
  def render_error
39
39
  controller.render(
40
- render_options.merge(
40
+ **render_options.merge(
41
41
  json: error_render_options,
42
42
  status: error_status
43
43
  )
@@ -65,9 +65,17 @@ module JsonApiResponders
65
65
 
66
66
  errors[:errors] << { detail: on_error(:detail) } if on_error(:detail)
67
67
 
68
- resource.errors.each do |attribute, message|
69
- errors[:errors] << error_response(attribute, message)
70
- end if resource.respond_to?(:errors)
68
+ if resource.respond_to?(:errors)
69
+ if ::ActiveModel.version >= Gem::Version.new("6.1")
70
+ resource.errors.each do |error|
71
+ errors[:errors] << error_response(error.attribute, error.message)
72
+ end
73
+ else
74
+ resource.errors.each do |attribute, message|
75
+ errors[:errors] << error_response(attribute, message)
76
+ end
77
+ end
78
+ end
71
79
 
72
80
  errors
73
81
  end
@@ -1,6 +1,6 @@
1
1
  module JsonApiResponders
2
2
  MAJOR = 2
3
- MINOR = 4
3
+ MINOR = 7
4
4
  PATCH = 0
5
5
  VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
6
6
  end
@@ -1,3 +1,5 @@
1
+ require 'active_model'
2
+
1
3
  require 'json_api_responders/version'
2
4
  require 'json_api_responders/errors'
3
5
  require 'json_api_responders/responder'
@@ -24,7 +26,7 @@ module JsonApiResponders
24
26
  def respond_with(resource, options = {})
25
27
  options = { params: params }.merge(options)
26
28
  JsonApiResponders.config.check_required_options(options)
27
- Responder.new(self, resource, options).respond!
29
+ Responder.new(self, resource, **options).respond!
28
30
  end
29
31
 
30
32
  def respond_with_error(status, detail = nil)
@@ -38,7 +40,7 @@ module JsonApiResponders
38
40
  end
39
41
 
40
42
  def parameter_missing!(reason)
41
- respond_with_error(:parameter_missing, reason.message)
43
+ respond_with_error(:unprocessable_entity, reason.message)
42
44
  end
43
45
 
44
46
  def json_api_parse_options
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_responders
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanko Krtalić Rusendić
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-05 00:00:00.000000000 Z
11
+ date: 2022-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activemodel
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Automatically respond to JSON::API requests
112
126
  email:
113
127
  - stanko.krtalic@gmail.com
@@ -116,11 +130,13 @@ extensions: []
116
130
  extra_rdoc_files: []
117
131
  files:
118
132
  - ".codeclimate.yml"
133
+ - ".github/workflows/test.yml"
119
134
  - ".gitignore"
120
135
  - ".rspec"
121
136
  - ".rubocop.yml"
122
137
  - ".travis.yml"
123
138
  - Gemfile
139
+ - Gemfile.lock
124
140
  - README.md
125
141
  - Rakefile
126
142
  - bin/console
@@ -137,7 +153,7 @@ homepage: https://github.com/infinum/json_api_responders
137
153
  licenses: []
138
154
  metadata:
139
155
  allowed_push_host: https://rubygems.org
140
- post_install_message:
156
+ post_install_message:
141
157
  rdoc_options: []
142
158
  require_paths:
143
159
  - lib
@@ -152,9 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
168
  - !ruby/object:Gem::Version
153
169
  version: '0'
154
170
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.7.3
157
- signing_key:
171
+ rubygems_version: 3.2.3
172
+ signing_key:
158
173
  specification_version: 4
159
174
  summary: Automatically respond to JSON::API requests
160
175
  test_files: []