rumbrl 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rumbrl/smash.rb +3 -4
- data/lib/rumbrl/version.rb +1 -1
- data/spec/rumbrl/smash_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84d0262471cebd69cf1a604c7f2dd221efa8138f
|
4
|
+
data.tar.gz: 8940adf061ecdbfb684a3672afb9bdf864495262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76f38bcbb4deae96405f57f5082cc573c8d3631fca12cede47430e365fb3a95c054cc93dc5be716ec4517b1dd8fb1be2243e4b6715870b61dc68fca317c2cd42
|
7
|
+
data.tar.gz: 4e6c8c0377074d4f67b3301707f5254b48814068c3f291c64a42a3f4295053d670950746641dbb3f3428710a139c907f1b08f9c2b451e688c7867dbb9351d7e3
|
data/Gemfile.lock
CHANGED
data/lib/rumbrl/smash.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module Rumbrl
|
2
2
|
# serializes & flattens hashes
|
3
3
|
class Smash
|
4
|
-
def self.flatten(namespace: ''
|
4
|
+
def self.flatten(target, namespace: '')
|
5
5
|
res = {}
|
6
|
-
|
7
|
-
target.each do |k, v|
|
6
|
+
target.each_pair do |k, v|
|
8
7
|
cur_nspace = build_namespace(namespace, k)
|
9
8
|
if v.is_a? Hash
|
10
|
-
res.update flatten(
|
9
|
+
res.update flatten(v, namespace: cur_nspace)
|
11
10
|
next
|
12
11
|
end
|
13
12
|
res[cur_nspace.to_sym] = v
|
data/lib/rumbrl/version.rb
CHANGED
data/spec/rumbrl/smash_spec.rb
CHANGED
@@ -12,6 +12,12 @@ describe Rumbrl::Smash do
|
|
12
12
|
flattened = { bar: 'foo', baz_wee: 'boo' }
|
13
13
|
expect(Rumbrl::Smash.flatten(target)).to eql flattened
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'flattens nested hashes with mixed keys' do
|
17
|
+
target = { 'bar' => 'foo', baz: { 'wee' => 'boo' } }
|
18
|
+
flattened = { bar: 'foo', baz_wee: 'boo' }
|
19
|
+
expect(Rumbrl::Smash.flatten(target)).to eql flattened
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
23
|
describe '.build_namespace' do
|