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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc82af5529740703aec6e83ed9b4464b81b2fb9f
4
- data.tar.gz: f34cac33f367edb3a0831ab58d95cef6d83a05e2
3
+ metadata.gz: 84d0262471cebd69cf1a604c7f2dd221efa8138f
4
+ data.tar.gz: 8940adf061ecdbfb684a3672afb9bdf864495262
5
5
  SHA512:
6
- metadata.gz: f85a35b5aabadcfeef69b3a354e4c4a24f59cfcfe68ae5f891c9f7c6fae6ca91d63ee0af9f1bdb1dfe4574f221b22d48551ef06fc429f10f41b264d82435d2d1
7
- data.tar.gz: 8f7bca73de095dd2fe4203410d5150ae20ee0929a4b0371b387303807249044c9fdd5137e5b922ae1c3fe0186e9e7adeba2b12d91b4052972144ab5a3d7c7f5c
6
+ metadata.gz: 76f38bcbb4deae96405f57f5082cc573c8d3631fca12cede47430e365fb3a95c054cc93dc5be716ec4517b1dd8fb1be2243e4b6715870b61dc68fca317c2cd42
7
+ data.tar.gz: 4e6c8c0377074d4f67b3301707f5254b48814068c3f291c64a42a3f4295053d670950746641dbb3f3428710a139c907f1b08f9c2b451e688c7867dbb9351d7e3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rumbrl (1.0.0)
4
+ rumbrl (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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: '', **target)
4
+ def self.flatten(target, namespace: '')
5
5
  res = {}
6
- # flattens a hash
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(**v, namespace: cur_nspace)
9
+ res.update flatten(v, namespace: cur_nspace)
11
10
  next
12
11
  end
13
12
  res[cur_nspace.to_sym] = v
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version const for gem
4
4
  module Rumbrl
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumbrl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - chr0n1x