simply_serializable 1.3.0 → 1.4.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: ed7754c68910d4556534b53f8475b8c36d1ad9259408508523c3bbd5463d0157
4
- data.tar.gz: 39eb74d95beb65aee78582fba369bbe5bd76ef082ad9d5a5cedf28f5d738ceb3
3
+ metadata.gz: 3c8d4b8bac053837979a76fd390dd98f9d4d1c979abb46b3f17a2f3094d54113
4
+ data.tar.gz: f78b56037f33b5484c018128ac0137e40617bc4ee08007620c8b875c341b58d7
5
5
  SHA512:
6
- metadata.gz: 90156f91281bb1fdf486351962b3380ee430866feea4418f2644d72e07d4f60c3346459b7125e81e3141bdcd488e626be0aa4f9572782a9eb1b3dbd6d6f09f03
7
- data.tar.gz: 455a807775db2e60c18f670e2c8ed080cd8995d3164c356e33897919c3af71315c26d21cdd038831f07246ca1c22acb1fe3873db1803d72f69420665392c0ab9
6
+ metadata.gz: 1e758c6b099e9ef620b4917850471d96e1f9dbf834cc7352a294fd67c428c38af55c556713894abe2a91d812c94c9f0fb8c8ca5fd58b5ca7df777405b30c610c
7
+ data.tar.gz: 112f164154044178c370deb26801fa6a7095e4d3c8fc7d4c39bc4459a66b68ce942daaaf7eb7c942306eb1dcfe595f264055ee746088c57f8cc4a8802b480bb0
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/Gemfile.lock CHANGED
@@ -1,18 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simply_serializable (1.3.0)
4
+ simply_serializable (1.4.0)
5
5
  fingerprintable (>= 1.2.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  awesome_print (1.8.0)
11
+ bump (0.8.0)
11
12
  byebug (11.0.1)
12
13
  colorize (0.8.1)
14
+ coveralls (0.8.23)
15
+ json (>= 1.8, < 3)
16
+ simplecov (~> 0.16.1)
17
+ term-ansicolor (~> 1.3)
18
+ thor (>= 0.19.4, < 2.0)
19
+ tins (~> 1.6)
13
20
  diff-lcs (1.3)
21
+ docile (1.3.2)
14
22
  fingerprintable (1.2.1)
15
23
  colorize
24
+ json (2.2.0)
16
25
  rake (10.5.0)
17
26
  rspec (3.8.0)
18
27
  rspec-core (~> 3.8.0)
@@ -27,17 +36,28 @@ GEM
27
36
  diff-lcs (>= 1.2.0, < 2.0)
28
37
  rspec-support (~> 3.8.0)
29
38
  rspec-support (3.8.0)
39
+ simplecov (0.16.1)
40
+ docile (~> 1.1)
41
+ json (>= 1.8, < 3)
42
+ simplecov-html (~> 0.10.0)
43
+ simplecov-html (0.10.2)
44
+ term-ansicolor (1.7.1)
45
+ tins (~> 1.0)
46
+ thor (0.20.3)
47
+ tins (1.20.3)
30
48
 
31
49
  PLATFORMS
32
50
  ruby
33
51
 
34
52
  DEPENDENCIES
35
53
  awesome_print
54
+ bump
36
55
  bundler (~> 2.0)
37
56
  byebug
57
+ coveralls
38
58
  rake (~> 10.0)
39
59
  rspec (~> 3.0)
40
60
  simply_serializable!
41
61
 
42
62
  BUNDLED WITH
43
- 2.0.1
63
+ 2.0.2
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # SimplySerializable
2
2
 
3
+ [![Build Status](https://travis-ci.org/ryanwjackson/simply_serializable.svg?branch=master)](https://travis-ci.org/ryanwjackson/simply_serializable) [![Coverage Status](https://coveralls.io/repos/github/ryanwjackson/simply_serializable/badge.svg?branch=master)](https://coveralls.io/github/ryanwjackson/simply_serializable?branch=master)
4
+
3
5
  SimplySerializable (SS) is a lightweight gem for serializing objects. It does not follow the JSON API structure, so as to optimizing for cycles and speed.
4
6
 
5
7
  ## Installation
@@ -3,6 +3,7 @@
3
3
  module SimplySerializable
4
4
  class Serializer
5
5
  attr_reader :attributes,
6
+ :do_not_serialize_if_class_is,
6
7
  :except,
7
8
  :object,
8
9
  :only
@@ -10,6 +11,7 @@ module SimplySerializable
10
11
  def initialize(
11
12
  attributes: [],
12
13
  cache: {},
14
+ do_not_serialize_if_class_is: [],
13
15
  except: nil,
14
16
  include_readable_instance_variables: true,
15
17
  method_prefix: :serialize,
@@ -19,6 +21,8 @@ module SimplySerializable
19
21
  @object = object
20
22
  @id = id
21
23
  @attributes = attributes
24
+ @do_not_serialize_if_class_is = do_not_serialize_if_class_is || []
25
+ @do_not_serialize_if_class_is = [@do_not_serialize_if_class_is] unless @do_not_serialize_if_class_is.is_a?(Array)
22
26
  @include_readable_instance_variables = include_readable_instance_variables
23
27
  @except = except&.map(&:to_sym)
24
28
  @only = only&.map(&:to_sym)
@@ -97,6 +101,8 @@ module SimplySerializable
97
101
 
98
102
  def deep_serialize(obj)
99
103
  case obj
104
+ when *do_not_serialize_if_class_is
105
+ obj
100
106
  when FalseClass, Float, nil, Integer, String, Symbol, TrueClass
101
107
  obj
102
108
  when Array
@@ -160,7 +166,8 @@ module SimplySerializable
160
166
  @nestable = false
161
167
  return reference_to(use_object_cache_key)
162
168
  end
163
- serializer = unless use_object.respond_to?(:serialize)
169
+
170
+ serializer = if !use_object.respond_to?(:serialize)
164
171
  raise "#{use_object.class.name} does not respond to serialize. Did you mean to include Serializable in this class?" unless @include_readable_instance_variables
165
172
 
166
173
  Serializer.new(
@@ -170,7 +177,7 @@ module SimplySerializable
170
177
  else
171
178
  use_object.serializer(cache: @local_cache)
172
179
  end
173
- serializer
180
+
174
181
  @local_cache.merge!(serializer.cache)
175
182
  reference_to(use_object_cache_key)
176
183
  end
@@ -1,3 +1,3 @@
1
1
  module SimplySerializable
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -26,8 +26,10 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency 'fingerprintable', '>= 1.2.1'
28
28
  spec.add_development_dependency 'awesome_print'
29
+ spec.add_development_dependency 'bump'
29
30
  spec.add_development_dependency 'bundler', '~> 2.0'
30
31
  spec.add_development_dependency 'byebug', '>= 0'
32
+ spec.add_development_dependency 'coveralls', '>= 0'
31
33
  spec.add_development_dependency 'rake', '~> 10.0'
32
34
  spec.add_development_dependency 'rspec', '~> 3.0'
33
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simply_serializable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jackson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2019-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fingerprintable
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bump
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rake
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +131,7 @@ executables: []
103
131
  extensions: []
104
132
  extra_rdoc_files: []
105
133
  files:
134
+ - ".coveralls.yml"
106
135
  - ".gitignore"
107
136
  - ".rspec"
108
137
  - ".travis.yml"
@@ -140,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
169
  - !ruby/object:Gem::Version
141
170
  version: '0'
142
171
  requirements: []
143
- rubygems_version: 3.0.3
172
+ rubygems_version: 3.0.4
144
173
  signing_key:
145
174
  specification_version: 4
146
175
  summary: Simply Serializable makes it easy to serialize any object.