cinnamon_serial 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/cinnamon_serial.gemspec +2 -2
- data/lib/cinnamon_serial/base.rb +8 -1
- data/lib/cinnamon_serial/cinnamon_serial.rb +1 -0
- data/lib/cinnamon_serial/version.rb +1 -1
- data/spec/base_spec.rb +12 -0
- data/spec/examples.rb +4 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4b1f1e130c735d90a575a5526bb4ff4b8d1b8e7
|
4
|
+
data.tar.gz: b021efb4fd143f8deb4ed52392b2227c0873e643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48a8172d0abc8757bd2ffaa53e3aed4b02b9f982edf0ec9d7c6be8a4f2dfde9d83c46ccb900a31d55efb7c9938385b298192bff0dfbbd7a8175e673a26b9569e
|
7
|
+
data.tar.gz: a6c314e747ad984603bcbe3975e0254f481f12fdd7aed6f5aff5b9c34852027d09471d5029bba6691392a187ed951fbb6468d47fef31d2ddad8c463eaa037744
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cinnamon_serial (2.
|
4
|
+
cinnamon_serial (2.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -48,8 +48,8 @@ PLATFORMS
|
|
48
48
|
|
49
49
|
DEPENDENCIES
|
50
50
|
cinnamon_serial!
|
51
|
-
pry
|
52
|
-
rspec
|
51
|
+
pry (~> 0.11)
|
52
|
+
rspec (~> 3.8)
|
53
53
|
rubocop (~> 0.59.2)
|
54
54
|
|
55
55
|
BUNDLED WITH
|
data/cinnamon_serial.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.required_ruby_version = '>= 2.3.1'
|
23
23
|
|
24
|
-
s.add_development_dependency('pry')
|
25
|
-
s.add_development_dependency('rspec')
|
24
|
+
s.add_development_dependency('pry', '~> 0.11')
|
25
|
+
s.add_development_dependency('rspec', '~> 3.8')
|
26
26
|
s.add_development_dependency('rubocop', '~> 0.59.2')
|
27
27
|
end
|
data/lib/cinnamon_serial/base.rb
CHANGED
@@ -24,7 +24,7 @@ module CinnamonSerial
|
|
24
24
|
:klasses
|
25
25
|
|
26
26
|
def initialize(obj, opts = {}, klasses = Set.new)
|
27
|
-
@obj = obj
|
27
|
+
@obj = normalize_object(obj)
|
28
28
|
@opts = opts || {}
|
29
29
|
@klasses = klasses
|
30
30
|
|
@@ -91,5 +91,12 @@ module CinnamonSerial
|
|
91
91
|
|
92
92
|
nil
|
93
93
|
end
|
94
|
+
|
95
|
+
# We would like to support hashes, but would rather stay object-based. So what we
|
96
|
+
# can do is just simply convert hashes to OpenStruct objects so they behave more like
|
97
|
+
# objects.
|
98
|
+
def normalize_object(obj)
|
99
|
+
obj.is_a?(Hash) ? OpenStruct.new(obj) : obj
|
100
|
+
end
|
94
101
|
end
|
95
102
|
end
|
data/spec/base_spec.rb
CHANGED
@@ -116,4 +116,16 @@ describe CinnamonSerial::Base do
|
|
116
116
|
it 'should not create cycles when flattening out presenters' do
|
117
117
|
expect(data['manager'].employees).to be nil
|
118
118
|
end
|
119
|
+
|
120
|
+
it 'should treat hashes like objects' do
|
121
|
+
employee = {
|
122
|
+
id: 1,
|
123
|
+
name: 'Mittens the cat'
|
124
|
+
}
|
125
|
+
|
126
|
+
serializer = SimpleEmployeeSerializer.new(employee)
|
127
|
+
|
128
|
+
expect(serializer.data['id']).to eq(employee[:id])
|
129
|
+
expect(serializer.data['name']).to eq(employee[:name])
|
130
|
+
end
|
119
131
|
end
|
data/spec/examples.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinnamon_serial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.11'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.8'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|