sanger-jsonapi-resources 0.1.1 → 0.1.3

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: b9bc1314c078c61f44653dd5aa8b24e271853bf8be84b5d41eced75795b56ad2
4
- data.tar.gz: deee25658162d4971d977153214a2373db3599708f4c69d94d8662a5f90cdcfd
3
+ metadata.gz: 41ebb993c7cbfaceff000cffb66c33e03242eb93f32f898676b78cf633fa835c
4
+ data.tar.gz: 334f92079b8036bcafcc12647965bc82181a609f3773bd54e88f1041e533f9de
5
5
  SHA512:
6
- metadata.gz: 24e0ea2c4aa90ceab8dd3b5a5f38a127566a1e8bc7b58d83b1e5f22a488df0f4bc1eeef8685a0fd60ff35efdbed68ca75be6d9b662f6a0da95fa150da783dadd
7
- data.tar.gz: baee2a71eff19ef87efc2e6223ae93b5d47e346859cf777bf197f377eefe5dda886627c2bfa65a90294dda427b8f3724580ed85e887a3ff0d19435c5b9a0aca0
6
+ metadata.gz: 8f82eb2c975059c4f0745f08bcf6d9243a48440ae430d9b1f2855386e59d3404dbde639776c114a5e6449788c5be0af766d3d6b4569af2903b1d65fb95169e55
7
+ data.tar.gz: a423295e281436746d3eecc5edd6ead5377d1ab1ec71ff6322500314eaa45761fc1d5a4b028e4ec18d6b989b33a5c6e240c14b210a1db8c690f61eb11b46cb0d
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # JSONAPI::Resources [![Gem Version](https://badge.fury.io/rb/jsonapi-resources.svg)](https://badge.fury.io/rb/jsonapi-resources) [![Build Status](https://secure.travis-ci.org/cerebris/jsonapi-resources.svg?branch=beta)](http://travis-ci.org/cerebris/jsonapi-resources) [![Code Climate](https://codeclimate.com/github/cerebris/jsonapi-resources/badges/gpa.svg)](https://codeclimate.com/github/cerebris/jsonapi-resources)
2
-
3
- [![Join the chat at https://gitter.im/cerebris/jsonapi-resources](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cerebris/jsonapi-resources?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1
+ # JSONAPI::Resources (Sanger fork)
4
2
 
5
3
  `JSONAPI::Resources`, or "JR", provides a framework for developing an API server that complies with the
6
4
  [JSON:API](http://jsonapi.org/) specification.
@@ -8,12 +6,12 @@
8
6
  Like JSON:API itself, JR's design is focused on the resources served by an API. JR needs little more than a definition
9
7
  of your resources, including their attributes and relationships, to make your server compliant with JSON API.
10
8
 
11
- JR is designed to work with Rails 4.2+, and provides custom routes, controllers, and serializers. JR's resources may be
9
+ JR is designed to work with Rails 5.1+, and provides custom routes, controllers, and serializers. JR's resources may be
12
10
  backed by ActiveRecord models or by custom objects.
13
11
 
14
12
  ## Documentation
15
13
 
16
- Full documentation can be found at [http://jsonapi-resources.com](http://jsonapi-resources.com), including the [v0.9 beta Guide](http://jsonapi-resources.com/v0.9/guide/) specific to this version.
14
+ Full documentation can be found at [http://jsonapi-resources.com](http://jsonapi-resources.com), including the [v0.10 alpha Guide](http://jsonapi-resources.com/v0.10/guide/) specific to this version.
17
15
 
18
16
  ## Demo App
19
17
 
@@ -22,32 +20,75 @@ We have a simple demo app, called [Peeps](https://github.com/cerebris/peeps), av
22
20
  ## Client Libraries
23
21
 
24
22
  JSON:API maintains a (non-verified) listing of [client libraries](http://jsonapi.org/implementations/#client-libraries)
25
- which *should* be compatible with JSON:API compliant server implementations such as JR.
23
+ which _should_ be compatible with JSON:API compliant server implementations such as JR.
26
24
 
27
25
  ## Installation
28
26
 
29
27
  Add JR to your application's `Gemfile`:
30
28
 
31
- gem 'sanger-jsonapi-resources'
29
+ ```
30
+ gem 'jsonapi-resources'
31
+ ```
32
32
 
33
33
  And then execute:
34
34
 
35
- $ bundle
35
+ ```bash
36
+ bundle
37
+ ```
36
38
 
37
39
  Or install it yourself as:
38
40
 
39
- $ gem install sanger-jsonapi-resources
41
+ ```bash
42
+ gem install jsonapi-resources
43
+ ```
44
+
45
+ **For further usage see the [v0.10 alpha Guide](http://jsonapi-resources.com/v0.10/guide/)**
46
+
47
+ ## Sanger-specific release process
48
+
49
+ There are two versions of the gem which we use for production. The version 1 series has unique customisations and is used by Sequencescape. The version 2 series is a more generic version which is used by Traction.
50
+
51
+ Check which versions we have published at https://rubygems.org/gems/sanger-jsonapi-resources
52
+
53
+ ### For version 1 series
54
+
55
+ - Create a branch from **develop**, apply fixes.
56
+ - Change version number in `lib/jsonapi/resources/version.rb` . This file is read by the gemspec during publication.
57
+ - Test Sequencescape with the gem from the branch.
58
+ - Merge the branch into develop.
59
+ <!-- list separator -->
60
+ - Checkout the develop branch.
61
+ - Execute `gem build jsonapi-resources.gemspec` which builds sanger-jsonapi-resources-0.1.x.gem in this case.
62
+ - Execute `gem push sanger-jsonapi-resources-0.1.x.gem` which publishes the gem.
63
+
64
+ ### For version 2 series
65
+
66
+ - Create a branch from **master**, apply fixes.
67
+ - Change version number in `lib/jsonapi/resources/version.rb` . This file is read by the gemspec during publication.
68
+ - Test Traction with the gem from the branch.
69
+ - Merge the branch into master.
70
+ <!-- list separator -->
71
+ - Checkout the master branch.
72
+ - Execute `gem build jsonapi-resources.gemspec` which builds sanger-jsonapi-resources-0.2.x.gem in this case.
73
+ - Execute `gem push sanger-jsonapi-resources-0.2.x.gem` which publishes the gem.
74
+
75
+ ### Publication
76
+
77
+ You will be notified by email for each. You will also receive one email for API key setup. The first push will ask email and password for the account, which are in KeePass (search for "gem").
78
+
79
+ > [!TIP]
80
+ > The process above can be improved by creating new releases first and then publish gems from those releases (tags) rather than publications from master (0.2) and develop (0.1) branches. Still create the releases to make tags in this work though.
81
+
82
+ > [!NOTE]
83
+ > The email and password for gem publication is a recent addition to the credentials database. Pull latest changes in the credentials repo.
40
84
 
41
- **For further usage see the [v0.9 beta Guide](http://jsonapi-resources.com/v0.9/guide/)**
85
+ > [!IMPORTANT]
86
+ > Developers need to execute `bundle install`.
42
87
 
43
88
  ## Contributing
44
89
 
45
- 1. Fork it ( http://github.com/cerebris/jsonapi-resources/fork )
46
- 2. Create your feature branch (`git checkout -b my-new-feature`)
47
- 3. Commit your changes (`git commit -am 'Add some feature'`)
48
- 4. Push to the branch (`git push origin my-new-feature`)
49
- 5. Create a new Pull Request
90
+ See CONTRIBUTING.md for details.
50
91
 
51
92
  ## License
52
93
 
53
- Copyright 2014-2016 Cerebris Corporation. MIT License (see LICENSE for details).
94
+ Copyright 2014-2021 Cerebris Corporation. MIT License (see LICENSE for details).
data/lib/jsonapi/error.rb CHANGED
@@ -15,7 +15,7 @@ module JSONAPI
15
15
  @source = options[:source]
16
16
  @links = options[:links]
17
17
 
18
- @status = Rack::Utils::SYMBOL_TO_STATUS_CODE[options[:status]].to_s
18
+ @status = status_code(options[:status]).to_s
19
19
  @meta = options[:meta]
20
20
  end
21
21
 
@@ -24,6 +24,21 @@ module JSONAPI
24
24
  instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) unless instance_variable_get(var).nil? }
25
25
  hash
26
26
  end
27
+
28
+ private
29
+
30
+ # Extracted from Rack 2
31
+ def status_code(status)
32
+ if status.nil?
33
+ raise ArgumentError, "Status code is required"
34
+ end
35
+
36
+ if status.is_a?(Symbol)
37
+ Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(status) { raise ArgumentError, "Unrecognized status code #{status.inspect}" }
38
+ else
39
+ status.to_i
40
+ end
41
+ end
27
42
  end
28
43
 
29
44
  class Warning
@@ -475,7 +475,7 @@ module JSONAPI
475
475
 
476
476
  def json_api_error(attr_key, message)
477
477
  create_error_object(code: JSONAPI::VALIDATION_ERROR,
478
- status: :unprocessable_entity,
478
+ status: :unprocessable_content,
479
479
  title: message,
480
480
  detail: "#{format_key(attr_key)} - #{message}",
481
481
  source: { pointer: pointer(attr_key) },
@@ -500,7 +500,7 @@ module JSONAPI
500
500
  class SaveFailed < Error
501
501
  def errors
502
502
  [create_error_object(code: JSONAPI::SAVE_FAILED,
503
- status: :unprocessable_entity,
503
+ status: :unprocessable_content,
504
504
  title: I18n.translate('jsonapi-resources.exceptions.save_failed.title',
505
505
  default: 'Save failed or was cancelled'),
506
506
  detail: I18n.translate('jsonapi-resources.exceptions.save_failed.detail',
@@ -1,5 +1,6 @@
1
1
  require 'jsonapi/operation'
2
2
  require 'jsonapi/paginator'
3
+ require 'cgi'
3
4
 
4
5
  module JSONAPI
5
6
  class RequestParser
@@ -272,7 +273,7 @@ module JSONAPI
272
273
 
273
274
  sorts = []
274
275
  begin
275
- raw = URI.unescape(sort_criteria)
276
+ raw = CGI.unescape(sort_criteria)
276
277
  sorts += CSV.parse_line(raw)
277
278
  rescue CSV::MalformedCSVError
278
279
  fail JSONAPI::Exceptions::InvalidSortCriteria.new(format_key(@resource_klass._type), raw)
@@ -511,7 +511,7 @@ module JSONAPI
511
511
  check_reserved_attribute_name(attr)
512
512
 
513
513
  if (attr.to_sym == :id) && (options[:format].nil?)
514
- ActiveSupport::Deprecation.warn('Id without format is no longer supported. Please remove ids from attributes, or specify a format.')
514
+ ActiveSupport::Deprecation.new(nil, 'JSONAPI').warn('Id without format is no longer supported. Please remove ids from attributes, or specify a format.')
515
515
  end
516
516
 
517
517
  check_duplicate_attribute_name(attr) if options[:format].nil?
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Resources
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanger-jsonapi-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PSD Team - Wellcome Trust Sanger Institute
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-06-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -58,6 +57,20 @@ dependencies:
58
57
  - - ">="
59
58
  - !ruby/object:Gem::Version
60
59
  version: '0'
60
+ - !ruby/object:Gem::Dependency
61
+ name: minitest-mock
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
61
74
  - !ruby/object:Gem::Dependency
62
75
  name: minitest-spec-rails
63
76
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +85,20 @@ dependencies:
72
85
  - - ">="
73
86
  - !ruby/object:Gem::Version
74
87
  version: '0'
88
+ - !ruby/object:Gem::Dependency
89
+ name: minitest-reporters
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
75
102
  - !ruby/object:Gem::Dependency
76
103
  name: simplecov
77
104
  requirement: !ruby/object:Gem::Requirement
@@ -120,28 +147,54 @@ dependencies:
120
147
  requirements:
121
148
  - - ">="
122
149
  - !ruby/object:Gem::Version
123
- version: '4.1'
150
+ version: '7.1'
151
+ - - "<"
152
+ - !ruby/object:Gem::Version
153
+ version: '8.1'
124
154
  type: :runtime
125
155
  prerelease: false
126
156
  version_requirements: !ruby/object:Gem::Requirement
127
157
  requirements:
128
158
  - - ">="
129
159
  - !ruby/object:Gem::Version
130
- version: '4.1'
160
+ version: '7.1'
161
+ - - "<"
162
+ - !ruby/object:Gem::Version
163
+ version: '8.1'
131
164
  - !ruby/object:Gem::Dependency
132
165
  name: railties
133
166
  requirement: !ruby/object:Gem::Requirement
134
167
  requirements:
135
168
  - - ">="
136
169
  - !ruby/object:Gem::Version
137
- version: '4.1'
170
+ version: '7.1'
171
+ - - "<"
172
+ - !ruby/object:Gem::Version
173
+ version: '8.1'
138
174
  type: :runtime
139
175
  prerelease: false
140
176
  version_requirements: !ruby/object:Gem::Requirement
141
177
  requirements:
142
178
  - - ">="
143
179
  - !ruby/object:Gem::Version
144
- version: '4.1'
180
+ version: '7.1'
181
+ - - "<"
182
+ - !ruby/object:Gem::Version
183
+ version: '8.1'
184
+ - !ruby/object:Gem::Dependency
185
+ name: rack
186
+ requirement: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: '3.0'
191
+ type: :runtime
192
+ prerelease: false
193
+ version_requirements: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - "~>"
196
+ - !ruby/object:Gem::Version
197
+ version: '3.0'
145
198
  - !ruby/object:Gem::Dependency
146
199
  name: concurrent-ruby
147
200
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +273,6 @@ homepage: https://github.com/sanger/jsonapi-resources
220
273
  licenses:
221
274
  - MIT
222
275
  metadata: {}
223
- post_install_message:
224
276
  rdoc_options: []
225
277
  require_paths:
226
278
  - lib
@@ -228,15 +280,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
280
  requirements:
229
281
  - - ">="
230
282
  - !ruby/object:Gem::Version
231
- version: '2.1'
283
+ version: '3.2'
232
284
  required_rubygems_version: !ruby/object:Gem::Requirement
233
285
  requirements:
234
286
  - - ">="
235
287
  - !ruby/object:Gem::Version
236
288
  version: '0'
237
289
  requirements: []
238
- rubygems_version: 3.5.11
239
- signing_key:
290
+ rubygems_version: 3.6.9
240
291
  specification_version: 4
241
292
  summary: Easily support JSON API in Rails.
242
293
  test_files: []