jsonapi_suite 0.6.0 → 0.7.0

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
  SHA1:
3
- metadata.gz: 7c4f03bc7b18125b847fe930ff43153cc530db9b
4
- data.tar.gz: 69eb78d9ba6a3b74fdaac59388f40d5426df7f6f
3
+ metadata.gz: 20c30584db58af555eebe8d795d6f2193db7242a
4
+ data.tar.gz: fddb3f32da3ea124c97997e08e21ce404e63277d
5
5
  SHA512:
6
- metadata.gz: fa0191cf19661d72fb6f4325581d11de3ce077eae496581b4a8e28d098eacd66d344706186ad4913e49ccc5740f61c7a0f44d2b8867143d146a85dddbf67e1f8
7
- data.tar.gz: 96037711b14731a9b6305addea7f0547bafcac1013a96e5d9054a7e95dd2b24d6fde3d17ed2c041297cd29e65dea106dd814cac9173a15aba83343aa73d593a4
6
+ metadata.gz: 4436e2b3f93992f3c7e3323724335c7f0ea29f35f0115aaec3c9e7662d4c7340fc6e3f5857c82d899342e0b2a07d43304bf27f63a0e925fa82c50bc341abc403
7
+ data.tar.gz: b26fde744e318d8375185e5c864bb40ec837c152bc3150c647984d80dff88cb957efe6c54d11d6b56f59bfeab991c7669514d8ad1660145b28e78ca1e146680c
data/README.md CHANGED
@@ -4,6 +4,18 @@
4
4
 
5
5
  Easily build jsonapi.org-compatible APIs in Rails.
6
6
 
7
- [View Official Documentation](https://jsonapi-suite.github.io/jsonapi_suite)
7
+ [View Overview Documentation](https://jsonapi-suite.github.io/jsonapi_suite)
8
+
9
+ [View Tutorial/Sample applications](https://gist.github.com/richmolj/c7f1adca75f614bb71b27f259ff3c37a)
10
+
11
+ [View YARD documentation](https://jsonapi-suite.github.io/jsonapi_compliable)
12
+
13
+ [Join the Slack Channel](https://join.slack.com/t/jsonapi-suite/shared_invite/enQtMjkyMTA3MDgxNTQzLWVkMDM3NTlmNTIwODY2YWFkMGNiNzUzZGMzOTY3YmNmZjBhYzIyZWZlZTk4YmI1YTI0Y2M0OTZmZGYwN2QxZjg)
14
+
15
+ Direct Contact: richmolj@gmail.com
8
16
 
9
17
  Supports Rails >= 4.1
18
+
19
+ ### Upgrading
20
+
21
+ When upgrading the [jsonapi_compliable](https://github.com/jsonapi-suite/jsonapi_compliable) dependency to 0.11.x, please see [this note](https://github.com/jsonapi-suite/jsonapi_compliable/blob/master/README.md#upgrading-to-011x)
@@ -18,12 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'rails', ['>= 4.1', '< 6']
21
+ spec.add_dependency 'actionpack', ['>= 4.1', '< 6']
22
+ spec.add_dependency 'activesupport', ['>= 4.1', '< 6']
22
23
  spec.add_dependency 'strong_resources', '~> 0.6'
23
- spec.add_dependency 'jsonapi_compliable', '~> 0.6'
24
- spec.add_dependency 'jsonapi_errorable', '~> 0.1'
25
- spec.add_dependency 'jsonapi_spec_helpers', '~> 0.3'
26
- spec.add_dependency 'nested_attribute_reassignable', '~> 0.6'
24
+ spec.add_dependency 'jsonapi_compliable', '~> 0.11'
25
+ spec.add_dependency 'jsonapi_errorable', '~> 0.6'
27
26
 
28
27
  spec.add_development_dependency "bundler", "~> 1.12"
29
28
  spec.add_development_dependency "rake", "~> 10.0"
@@ -0,0 +1,54 @@
1
+ module JsonapiSuite
2
+ class InstallGenerator < ::Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ class_option :'omit-comments',
6
+ type: :boolean,
7
+ default: false,
8
+ aliases: ['-c'],
9
+ desc: 'Generate without documentation comments'
10
+
11
+ desc "This generator boostraps jsonapi-suite with an initialize and controller mixin"
12
+ def create_initializer
13
+ to = File.join('config/initializers', 'jsonapi.rb')
14
+ template('initializer.rb.erb', to)
15
+
16
+ to = File.join('config/initializers', "strong_resources.rb")
17
+ template('strong_resources.rb.erb', to)
18
+
19
+ inject_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::API\n" do
20
+ app_controller_code
21
+ end
22
+
23
+ inject_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do
24
+ app_controller_code
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def app_controller_code
31
+ str = ""
32
+ unless omit_comments?
33
+ str << " # Bootstrap jsonapi_suite with relevant modules\n"
34
+ end
35
+ str << " include JsonapiSuite::ControllerMixin\n"
36
+ str << "\n"
37
+ str << " register_exception JsonapiCompliable::Errors::RecordNotFound,\n"
38
+ str << " status: 404\n"
39
+ str << "\n"
40
+ unless omit_comments?
41
+ str << " # Catch all exceptions and render a JSONAPI-compliable error payload\n"
42
+ str << " # For additional documentation, see https://jsonapi-suite.github.io/jsonapi_errorable\n"
43
+ end
44
+ str << " rescue_from Exception do |e|\n"
45
+ str << " handle_exception(e)\n"
46
+ str << " end\n\n"
47
+ str
48
+ end
49
+
50
+ def omit_comments?
51
+ !!@options['omit-comments']
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ <%- unless omit_comments? -%>
2
+ # Require any adapters your app needs. Since you are using Rails,
3
+ # we'll start you off with ActiveRecord adapter.
4
+ #
5
+ # For further documentation on adapters, see https://jsonapi-suite.github.io/jsonapi_compliable/JsonapiCompliable/Adapters/Abstract.html
6
+ <%- end -%>
7
+ require 'jsonapi_compliable/adapters/active_record'
@@ -0,0 +1,36 @@
1
+ <%- unless omit_comments? -%>
2
+ # Define payloads that can be re-used across endpoints.
3
+ #
4
+ # For instance, you may create Tag objects via the /tags endpoint.
5
+ # You may also sidepost Tag objects via the /posts endpoint.
6
+ # Here is where the Tag payload can be defined. For example:
7
+ #
8
+ # strong_resource :tag do
9
+ # attribute :name, :string
10
+ # attribute :active, :boolean
11
+ # end
12
+ #
13
+ # You can now reference this payload across controllers:
14
+ #
15
+ # class TagsController < ApplicationController
16
+ # strong_resource :tag
17
+ # end
18
+ #
19
+ # class PostsController < ApplicationController
20
+ # strong_resource :post do
21
+ # has_many :tags, disassociate: true, destroy: true
22
+ # end
23
+ # end
24
+ #
25
+ # Custom types can be added here as well:
26
+ # Parameters = ActionController::Parameters
27
+ # strong_param :pet_type, swagger: :string, type: Parameters.enum('Dog', 'Cat')
28
+ #
29
+ # strong_resource :pet do
30
+ # attribute :type, :pet_type
31
+ # end
32
+ #
33
+ # For additional documentation, see https://jsonapi-suite.github.io/strong_resources
34
+ <%- end -%>
35
+ StrongResources.configure do
36
+ end
@@ -1,3 +1,3 @@
1
1
  module JsonapiSuite
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/jsonapi_suite.rb CHANGED
@@ -3,7 +3,6 @@ require 'jsonapi/include_directive'
3
3
  require 'strong_resources'
4
4
  require 'jsonapi_compliable'
5
5
  require 'jsonapi_errorable'
6
- require 'nested_attribute_reassignable'
7
6
 
8
7
  require "jsonapi_suite/version"
9
8
  require "jsonapi_suite/controller_mixin"
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_suite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-09 00:00:00.000000000 Z
11
+ date: 2018-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: actionpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -31,21 +31,27 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
- name: strong_resources
34
+ name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '0.6'
39
+ version: '4.1'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6'
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
- - - "~>"
47
+ - - ">="
45
48
  - !ruby/object:Gem::Version
46
- version: '0.6'
49
+ version: '4.1'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6'
47
53
  - !ruby/object:Gem::Dependency
48
- name: jsonapi_compliable
54
+ name: strong_resources
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - "~>"
@@ -59,35 +65,21 @@ dependencies:
59
65
  - !ruby/object:Gem::Version
60
66
  version: '0.6'
61
67
  - !ruby/object:Gem::Dependency
62
- name: jsonapi_errorable
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '0.1'
68
- type: :runtime
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '0.1'
75
- - !ruby/object:Gem::Dependency
76
- name: jsonapi_spec_helpers
68
+ name: jsonapi_compliable
77
69
  requirement: !ruby/object:Gem::Requirement
78
70
  requirements:
79
71
  - - "~>"
80
72
  - !ruby/object:Gem::Version
81
- version: '0.3'
73
+ version: '0.11'
82
74
  type: :runtime
83
75
  prerelease: false
84
76
  version_requirements: !ruby/object:Gem::Requirement
85
77
  requirements:
86
78
  - - "~>"
87
79
  - !ruby/object:Gem::Version
88
- version: '0.3'
80
+ version: '0.11'
89
81
  - !ruby/object:Gem::Dependency
90
- name: nested_attribute_reassignable
82
+ name: jsonapi_errorable
91
83
  requirement: !ruby/object:Gem::Requirement
92
84
  requirements:
93
85
  - - "~>"
@@ -160,6 +152,9 @@ files:
160
152
  - bin/console
161
153
  - bin/setup
162
154
  - jsonapi_suite.gemspec
155
+ - lib/generators/jsonapi_suite/install_generator.rb
156
+ - lib/generators/jsonapi_suite/templates/initializer.rb.erb
157
+ - lib/generators/jsonapi_suite/templates/strong_resources.rb.erb
163
158
  - lib/jsonapi_suite.rb
164
159
  - lib/jsonapi_suite/controller_mixin.rb
165
160
  - lib/jsonapi_suite/version.rb
@@ -183,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
178
  version: '0'
184
179
  requirements: []
185
180
  rubyforge_project:
186
- rubygems_version: 2.6.7
181
+ rubygems_version: 2.5.1
187
182
  signing_key:
188
183
  specification_version: 4
189
184
  summary: Collection of gems for jsonapi.org-compatible APIs