upholsterer 1.4.0 → 1.4.1
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 +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +1 -1
- data/Gemfile.lock +3 -3
- data/lib/upholsterer/json_presenter.rb +17 -15
- data/lib/upholsterer/rails.rb +1 -1
- data/lib/upholsterer/version.rb +1 -1
- data/spec/support/matchers/json_matcher.rb +23 -2
- data/upholsterer.gemspec +3 -3
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f86ecfdcf45ec231c8fbc8891e6434e365278a95
|
4
|
+
data.tar.gz: a9d6c734325567bf1a4fb1040782147bcd95688d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245da627ee9baab2a4f2422bb0a7103b1d1372f62a6e88e2c72c00704b430ab2c86796bee24f6908f3c4461171e0d1464c0b4a12d4ab0f1ea37f0f0f0f20064e
|
7
|
+
data.tar.gz: dc459f25c07027059bfb1897c0888b9c1919f2a95a7b2017fbe99578d1fc56e4eccfd12f0fc54507a5ff1ab75703e4a667ffd407d5cf206782ab8d65c05c76d8
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
upholsterer (1.4.
|
4
|
+
upholsterer (1.4.1)
|
5
5
|
activesupport
|
6
6
|
|
7
7
|
GEM
|
@@ -17,7 +17,7 @@ GEM
|
|
17
17
|
coderay (1.0.9)
|
18
18
|
diff-lcs (1.2.4)
|
19
19
|
i18n (0.6.11)
|
20
|
-
json (1.8.
|
20
|
+
json (1.8.3)
|
21
21
|
method_source (0.8.2)
|
22
22
|
minitest (5.4.2)
|
23
23
|
pry (0.9.12.2)
|
@@ -59,4 +59,4 @@ DEPENDENCIES
|
|
59
59
|
upholsterer!
|
60
60
|
|
61
61
|
BUNDLED WITH
|
62
|
-
1.
|
62
|
+
1.12.5
|
@@ -10,25 +10,27 @@ module Upholsterer
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
end]
|
17
|
-
end
|
18
|
-
|
19
|
-
alias :to_h :to_hash
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def json_fields
|
24
|
-
@json_fields ||= begin
|
25
|
-
methods = public_methods(false).tap do |fields|
|
13
|
+
def self.serialize_attributes
|
14
|
+
@_json_fields ||= begin
|
15
|
+
methods = instance_methods(false).tap do |fields|
|
26
16
|
fields.delete(:subject)
|
27
17
|
fields.delete(:respond_to?)
|
28
18
|
fields.delete(:method_missing)
|
29
19
|
end
|
30
|
-
(methods +
|
20
|
+
(methods + attributes.keys).uniq
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_hash
|
25
|
+
json = {}
|
26
|
+
|
27
|
+
self.class.serialize_attributes.each do |field|
|
28
|
+
json[field] = public_send(field)
|
31
29
|
end
|
30
|
+
|
31
|
+
json
|
32
32
|
end
|
33
|
+
|
34
|
+
alias :to_h :to_hash
|
33
35
|
end
|
34
|
-
end
|
36
|
+
end
|
data/lib/upholsterer/rails.rb
CHANGED
data/lib/upholsterer/version.rb
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
RSpec::Matchers.define :be_json_with do |expected|
|
2
2
|
match do |json_string|
|
3
|
-
|
3
|
+
current_hash = JSON.parse(json_string)
|
4
|
+
|
5
|
+
compare_hashes(current_hash, expected)
|
6
|
+
end
|
7
|
+
|
8
|
+
def compare_hashes(actual, expected)
|
9
|
+
if actual.keys.count == expected.keys.count
|
10
|
+
actual.all? do |key, value|
|
11
|
+
key = key.to_sym
|
12
|
+
if expected.has_key?(key)
|
13
|
+
expected_value = expected[key]
|
14
|
+
|
15
|
+
if value.is_a? Hash
|
16
|
+
if expected_value.is_a? Hash
|
17
|
+
compare_hashes(value, expected_value)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
expected_value == value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
4
25
|
end
|
5
26
|
end
|
6
27
|
|
@@ -15,4 +36,4 @@ RSpec::Matchers.define :contain_keys do |*expected|
|
|
15
36
|
false
|
16
37
|
end
|
17
38
|
end
|
18
|
-
end
|
39
|
+
end
|
data/upholsterer.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = 'upholsterer'
|
7
7
|
s.version = Upholsterer::Version::STRING
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ['
|
10
|
-
s.email = ['
|
9
|
+
s.authors = ['Aleksandr Fomin']
|
10
|
+
s.email = ['ll.wg.bin@gmail.com']
|
11
11
|
s.homepage = 'https://github.com/llxff/upholsterer'
|
12
|
-
s.summary = 'A simple
|
12
|
+
s.summary = 'A simple serializer implementation.'
|
13
13
|
s.description = s.summary
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upholsterer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Nando Vieira
|
8
7
|
- Aleksandr Fomin
|
9
|
-
- Gleb Sinyavsky
|
10
8
|
autorequire:
|
11
9
|
bindir: bin
|
12
10
|
cert_chain: []
|
13
|
-
date: 2016-
|
11
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
14
12
|
dependencies:
|
15
13
|
- !ruby/object:Gem::Dependency
|
16
14
|
name: rake
|
@@ -68,9 +66,8 @@ dependencies:
|
|
68
66
|
- - ">="
|
69
67
|
- !ruby/object:Gem::Version
|
70
68
|
version: '0'
|
71
|
-
description: A simple
|
69
|
+
description: A simple serializer implementation.
|
72
70
|
email:
|
73
|
-
- fnando.vieira@gmail.com
|
74
71
|
- ll.wg.bin@gmail.com
|
75
72
|
executables: []
|
76
73
|
extensions: []
|
@@ -124,8 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
121
|
version: '0'
|
125
122
|
requirements: []
|
126
123
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.5.1
|
128
125
|
signing_key:
|
129
126
|
specification_version: 4
|
130
|
-
summary: A simple
|
127
|
+
summary: A simple serializer implementation.
|
131
128
|
test_files: []
|