kartograph 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -6
- data/lib/kartograph/property.rb +2 -2
- data/lib/kartograph/version.rb +1 -1
- data/spec/lib/kartograph/property_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5af5f7be8e9504c342f95484c349619f678ff61
|
4
|
+
data.tar.gz: 99fd01c9d91b017907ed9716b24d9c28100ebde0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ef08180546de7f53a88f49960e36090ca36e77e8cdb83da34dd8b31b0d8f5334bbe92a00ce31be2b9ffec1ffa4cdeb1067965a978450229fc9f03133e71b1c
|
7
|
+
data.tar.gz: b4458ec9475057f8d92e8039a88424f5c07efe00d0475444fa572b75c234a8adec2e2af630fd263c0f504fcdd88e939a2c1bb9b72b61466e23ff65893492fefb
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Kartograph
|
2
2
|
|
3
|
-
|
3
|
+
A Serialization / Deserialization library.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -12,10 +12,6 @@ And then execute:
|
|
12
12
|
|
13
13
|
$ bundle
|
14
14
|
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install kartograph
|
18
|
-
|
19
15
|
## Usage
|
20
16
|
|
21
17
|
Kartograph makes it easy to generate and convert JSON. It's intention is to be used for API clients.
|
@@ -142,7 +138,7 @@ Now when JSON includes comments for a user, it will know how to map the comments
|
|
142
138
|
|
143
139
|
## Contributing
|
144
140
|
|
145
|
-
1. Fork it ( https://github.com/
|
141
|
+
1. Fork it ( https://github.com/digitaloceancloud/kartograph/fork )
|
146
142
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
147
143
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
148
144
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/kartograph/property.rb
CHANGED
@@ -54,11 +54,11 @@ module Kartograph
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def sculpt_value(value, scope)
|
57
|
-
plural? ? value.map {|v| Sculptor.new(v, map).sculpt(scope) } : Sculptor.new(value, map).sculpt(scope)
|
57
|
+
plural? ? Array(value).map {|v| Sculptor.new(v, map).sculpt(scope) } : Sculptor.new(value, map).sculpt(scope)
|
58
58
|
end
|
59
59
|
|
60
60
|
def artist_value(value, scope)
|
61
|
-
plural? ? value.map {|v| Artist.new(v, map).draw(scope) } : Artist.new(value, map).draw(scope)
|
61
|
+
plural? ? Array(value).map {|v| Artist.new(v, map).draw(scope) } : Artist.new(value, map).draw(scope)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/kartograph/version.rb
CHANGED
@@ -177,6 +177,24 @@ describe Kartograph::Property do
|
|
177
177
|
expect(value[1].id).to eq(hash[:hello][1]['id'])
|
178
178
|
expect(value[1].name).to eq(hash[:hello][1]['name'])
|
179
179
|
end
|
180
|
+
|
181
|
+
context 'when set to plural but the key is nil' do
|
182
|
+
it 'returns an empty array' do
|
183
|
+
dummy_class = Struct.new(:id, :name)
|
184
|
+
|
185
|
+
nested_property = Kartograph::Property.new(:hello, plural: true) do
|
186
|
+
mapping dummy_class
|
187
|
+
|
188
|
+
property :id
|
189
|
+
property :name
|
190
|
+
end
|
191
|
+
|
192
|
+
hash = { hello: nil }
|
193
|
+
value = nested_property.value_from(hash)
|
194
|
+
|
195
|
+
expect(value).to eq([])
|
196
|
+
end
|
197
|
+
end
|
180
198
|
end
|
181
199
|
end
|
182
200
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kartograph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Ross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|