knuckles 0.1.0 → 0.1.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/CHANGELOG.md +5 -0
- data/lib/knuckles/combiner.rb +3 -3
- data/lib/knuckles/dumper.rb +2 -2
- data/lib/knuckles/version.rb +1 -1
- data/spec/knuckles/combiner_spec.rb +8 -7
- data/spec/knuckles/dumper_spec.rb +4 -4
- 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: 5c87ae8cc3d3661d7f726b97cc65a6a14ddd1570
|
4
|
+
data.tar.gz: b9a84d855d7088f3808eeeba46311e6707f220e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 288a745e8475764d7322d8108ef201c93b9adc61f10469caad7b00d626d8598202c6e88baa775e1c82d6a18920371a3841aa259b036a33cefb05a230067b0a24
|
7
|
+
data.tar.gz: 0660c72b861d3405249949734808987969644f43ad6ce63b01b0b1d7166586908e44c1ca8f1bba73c434e7c6d6cfe3f01c4becb0fa65e86751fae694c72458f4
|
data/CHANGELOG.md
CHANGED
data/lib/knuckles/combiner.rb
CHANGED
@@ -9,7 +9,7 @@ module Knuckles
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(prepared, _)
|
12
|
-
prepared.each_with_object(
|
12
|
+
prepared.each_with_object(array_backed_hash) do |hash, memo|
|
13
13
|
hash[:result].each do |root, values|
|
14
14
|
case values
|
15
15
|
when Hash then memo[root] << values
|
@@ -19,8 +19,8 @@ module Knuckles
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
Hash.new { |hash, key| hash[key] =
|
22
|
+
def array_backed_hash
|
23
|
+
Hash.new { |hash, key| hash[key] = [] }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/knuckles/dumper.rb
CHANGED
data/lib/knuckles/version.rb
CHANGED
@@ -19,17 +19,18 @@ RSpec.describe Knuckles::Combiner do
|
|
19
19
|
combined = Knuckles::Combiner.call(prepared, {})
|
20
20
|
|
21
21
|
expect(combined).to eq(
|
22
|
-
author:
|
22
|
+
author: [
|
23
23
|
{id: 1, name: "Michael"}
|
24
|
-
]
|
25
|
-
posts:
|
24
|
+
],
|
25
|
+
posts: [
|
26
26
|
{id: 1, title: "hello", tag_ids: [1, 2]},
|
27
27
|
{id: 2, title: "there", tag_ids: [1]}
|
28
|
-
]
|
29
|
-
tags:
|
28
|
+
],
|
29
|
+
tags: [
|
30
30
|
{id: 1, name: "alpha"},
|
31
|
-
{id: 2, name: "gamma"}
|
32
|
-
|
31
|
+
{id: 2, name: "gamma"},
|
32
|
+
{id: 1, name: "alpha"}
|
33
|
+
]
|
33
34
|
)
|
34
35
|
end
|
35
36
|
end
|
@@ -3,14 +3,14 @@ RSpec.describe Knuckles::Dumper do
|
|
3
3
|
it "dumps a tree of objects" do
|
4
4
|
objects = {
|
5
5
|
author: {id: 1, name: "Ernest"},
|
6
|
-
posts:
|
6
|
+
posts: [
|
7
7
|
{id: 1, title: "great"},
|
8
8
|
{id: 2, title: "stuff"}
|
9
|
-
]
|
10
|
-
tags:
|
9
|
+
],
|
10
|
+
tags: [
|
11
11
|
{id: 1, name: "alpha"},
|
12
12
|
{id: 2, name: "gamma"}
|
13
|
-
]
|
13
|
+
]
|
14
14
|
}
|
15
15
|
|
16
16
|
dumped = Knuckles::Dumper.call(objects, {})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knuckles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Selbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|