json_api_toolbox 0.11.2 → 0.12.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
  SHA1:
3
- metadata.gz: d9bc39c5f0eda5a3f3e9eeeef989c54a49a8713e
4
- data.tar.gz: ab4b4f3ac07687d4e8338868b5b607b9f09240a0
3
+ metadata.gz: 1c07167e784b4b56414110ef63def3aac9c666bd
4
+ data.tar.gz: aa95ca274f2c296572908fbf11589e3c3d54ba97
5
5
  SHA512:
6
- metadata.gz: 2c717a12e33c1c90740d70df1fa4487bfdb3bd41d24d3a9d71562fce04b893230272e1f19698cf5db00a0be7d018d15dd7123dff52a7a423c127ea4c7fe781cb
7
- data.tar.gz: e9567bae5df7003ea647fac6966cfc95bb4a75f172f045c340fb474acc99a0db3d4d05f4494e70f112bac667c37195a03771f9fa495b6354c43fc6e812dc5b3b
6
+ metadata.gz: 61b9beec0e83c9bd2fdda9f3c0228f9fd5a755d2078d72b8efdaab8fa5390cc77901116fcbb7d5961b33df038c0ea86e7fe2b24b6e6de450721cf08b865da5ec
7
+ data.tar.gz: a267387af4d2e225e9233133605b6eafd9fa419db0cba7882f56471b2aec38f33f3530238ac20a7134721e80c52f1aee95f97e14c8b89ca347ab65aaa58d2b58
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.12.0] - 2018-04-03
10
+ ### Added
11
+ - Added JsonApi default exception renderizable
12
+
9
13
  ## [0.11.2] - 2018-03-14
10
14
  ### Fixed
11
15
  - Fixed rspec dependency
@@ -33,4 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'pry'
34
34
  spec.add_development_dependency 'pry-byebug'
35
35
  spec.add_development_dependency 'rake'
36
+ spec.add_development_dependency 'shoulda-matchers', '~> 3.1'
36
37
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'active_support/inflector'
4
4
  require 'renderizable'
5
+ require 'renderizable_exceptions'
5
6
  require 'enums'
6
7
  require 'postable'
7
8
  require 'service'
@@ -12,5 +13,6 @@ require_relative 'json_api_toolbox/spec_support/shared_examples_for_controllers'
12
13
  require_relative 'json_api_toolbox/serializables/serializable_enum_option'
13
14
  require_relative 'json_api_toolbox/serializables/serializable_job'
14
15
  require_relative 'json_api_toolbox/serializables/serializable_version'
16
+ require_relative 'json_api_toolbox/serializables/serializable_exception'
15
17
 
16
18
  module JsonApiToolbox; end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JsonApiToolbox
4
+ module Serializables
5
+ class SerializableException < JSONAPI::Serializable::Resource
6
+ attribute(:title) { @object[:title] }
7
+ attribute(:detail) { @object[:detail] }
8
+ attribute(:source) { @object[:source] }
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonApiToolbox
4
- VERSION = '0.11.2'
4
+ VERSION = '0.12.0'
5
5
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+ require 'pry'
5
+
6
+ module JsonApiToolbox
7
+ module RenderizableExceptions
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ rescue_from Exception, with: :render_any_exception
12
+ end
13
+
14
+ def render_any_exception(exception)
15
+ render(
16
+ jsonapi_errors: {
17
+ title: exception.class.to_s,
18
+ detail: exception.message,
19
+ source: {}
20
+ },
21
+ jsonapi_class: {
22
+ class: { Hash: JsonApiToolbox::Serializables::SerializableException }
23
+ }
24
+ )
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adriano Bacha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: shoulda-matchers
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '3.1'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '3.1'
209
223
  description:
210
224
  email:
211
225
  - abacha@gmail.com
@@ -227,12 +241,14 @@ files:
227
241
  - lib/json_api_toolbox.rb
228
242
  - lib/json_api_toolbox/paginable.rb
229
243
  - lib/json_api_toolbox/serializables/serializable_enum_option.rb
244
+ - lib/json_api_toolbox/serializables/serializable_exception.rb
230
245
  - lib/json_api_toolbox/serializables/serializable_job.rb
231
246
  - lib/json_api_toolbox/serializables/serializable_version.rb
232
247
  - lib/json_api_toolbox/spec_support/shared_examples_for_controllers.rb
233
248
  - lib/json_api_toolbox/version.rb
234
249
  - lib/postable.rb
235
250
  - lib/renderizable.rb
251
+ - lib/renderizable_exceptions.rb
236
252
  - lib/service.rb
237
253
  homepage: http://bitbucket.org/guideinvestimentos/json_api_toolbox
238
254
  licenses: []