jsonapi_suite 0.6.6 → 0.6.7

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: b293a213e22bb372bc8c87fb8e341f79ab46baaa
4
- data.tar.gz: 4ec742745959edbec72bf3d97c7e018f22bce7e3
3
+ metadata.gz: 958dcb4d91277ed10aad02acf0f21f4d0ab0789f
4
+ data.tar.gz: 29c1196b1f6211ec627ddfb88147c2d3ffb5450c
5
5
  SHA512:
6
- metadata.gz: 7dc14ebd0183c3fe3e18686a634dcb755e4bbed75c39b1ce23eab4785c7f5292c525aee9af385a503eab1388a538980237812fb2279565dd1d0c1ebf41775ac6
7
- data.tar.gz: b97d18d38a3a5c7f509bf1bdd401a9e37eaab7b653ef5726f2af6131dbbd6f927e6a543a784427919edfa7d3101b0b6e7523931722d56d41519ccfebba3d95c6
6
+ metadata.gz: 5a53116286cc3d7f4d32aaa19915a184d8608d4ac2dc06ded62147d7bde0654aef8cf0dff763fa7a2b96f4d6b02216d96b0f215c585d6e66f7b7c0813ce25da8
7
+ data.tar.gz: a80a9a55314cad23ed685da79c6bea4320c7b5b5b82351c8e459d94a0f819fbe83de6dbca962af4a63265fbd8d8caad04f6b4d49acc4fd7dba94ad64e82e22bb
@@ -2,9 +2,12 @@ module JsonapiSuite
2
2
  class InstallGenerator < ::Rails::Generators::Base
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
- # spec helpers to test?
6
- # gem 'jsonapi-rails', '~> 0.1'
7
- # require 'jsonapi_compliable/adapters/active_record'
5
+ class_option :'omit-comments',
6
+ type: :boolean,
7
+ default: false,
8
+ aliases: ['-c'],
9
+ desc: 'Generate without documentation comments'
10
+
8
11
  desc "This generator boostraps jsonapi-suite with an initialize and controller mixin"
9
12
  def create_initializer
10
13
  to = File.join('config/initializers', 'jsonapi.rb')
@@ -13,15 +16,35 @@ module JsonapiSuite
13
16
  to = File.join('config/initializers', "strong_resources.rb")
14
17
  template('strong_resources.rb.erb', to)
15
18
 
16
- inject_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::API\n" do <<-'RUBY'
17
- include JsonapiSuite::ControllerMixin
18
- RUBY
19
- end
19
+ inject_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::API\n" do
20
+ app_controller_code
21
+ end
20
22
 
21
- inject_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do <<-'RUBY'
22
- include JsonapiSuite::ControllerMixin
23
- RUBY
24
- end
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\n"
36
+ unless omit_comments?
37
+ str << " # Catch all exceptions and render a JSONAPI-compliable error payload\n"
38
+ str << " # For additional documentation, see https://jsonapi-suite.github.io/jsonapi_errorable\n"
39
+ end
40
+ str << " rescue_from Exception do |e|\n"
41
+ str << " handle_exception(e)\n"
42
+ str << " end\n"
43
+ str
44
+ end
45
+
46
+ def omit_comments?
47
+ !!@options['omit-comments']
25
48
  end
26
49
  end
27
50
  end
@@ -1 +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 -%>
1
7
  require 'jsonapi_compliable/adapters/active_record'
@@ -1,2 +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 -%>
1
35
  StrongResources.configure do
2
36
  end
@@ -1,3 +1,3 @@
1
1
  module JsonapiSuite
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_suite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
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-05-24 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack