pandarus 0.6.0 → 0.6.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: a0e31cee916d90794168ab36f9aacdfbbe6439ec
4
- data.tar.gz: 132801e9f46e9384b94be14fb582a95266839f54
3
+ metadata.gz: eb117275ee83932fa8690bc9cb80edf68f1ef28e
4
+ data.tar.gz: f4e7c0c6be59acb8aa08826119f55a6a020945d1
5
5
  SHA512:
6
- metadata.gz: 2477741b2c6501f1438e0b41736646d26f95c0a2fbc00afcd10a61d81f20349ce6355dc8adc4c96ae31d70c306cd415dc3e5fd9de654536ca15aa5f337faef54
7
- data.tar.gz: e3084d6934c97c1a523664f9a166faf2fb7e0f6bf6eea8efd3acae336aa4bcf5d6f2cce1d1fc08ac2940412fde6fcda146f8361d08afae68acab9bb8e8776fe3
6
+ metadata.gz: c0870023cd3e7553079dce84eb953dfddf76e9cb06540c62aae7a1c4bdd9ef1038e9e17a3d2671ae68e783dd73f1f8e114a4acece3b89bce5bf27d9d2ede4a22
7
+ data.tar.gz: 0b123de59fa0cecd0fd0f222d28118806b001a86d72657f49ff6d3db7f242c446da5c095b81a07101fc40238476b5451928cce0fb78ec484eb6a7449fe963bd6
@@ -65,7 +65,7 @@ module Pandarus
65
65
  end
66
66
 
67
67
  def dot_flatten_hash(hash)
68
- Hash[*dot_flatten_recur(hash).flatten]
68
+ Hash[dot_flatten_recur(hash)]
69
69
  end
70
70
 
71
71
  def dot_flatten_recur(hash)
@@ -73,7 +73,7 @@ module Pandarus
73
73
  if v1.is_a?(Hash)
74
74
  dot_flatten_recur(v1).map do |k2, v2|
75
75
  ["#{k1}.#{k2}", v2]
76
- end.flatten
76
+ end.flatten(1)
77
77
  else
78
78
  [k1, v1]
79
79
  end
@@ -1,3 +1,3 @@
1
1
  module Pandarus
2
- VERSION = '0.6.0' unless defined?(Pandarus::VERSION)
2
+ VERSION = '0.6.1' unless defined?(Pandarus::VERSION)
3
3
  end
@@ -2,13 +2,13 @@ require_relative 'spec_helper'
2
2
  require 'pandarus'
3
3
 
4
4
  describe Pandarus::APIBase do
5
+ let(:base) { Pandarus::APIBase.new }
6
+
5
7
  context "underscores_to_square_brackets" do
6
8
  def u2sb(string)
7
9
  base.send(:underscores_to_square_brackets, string)
8
10
  end
9
11
 
10
- let(:base) { Pandarus::APIBase.new }
11
-
12
12
  it "converts surrounding double underscores" do
13
13
  u2sb("prefix__inside__").should == :"prefix[inside]"
14
14
  end
@@ -22,4 +22,18 @@ describe Pandarus::APIBase do
22
22
  :"prefix[alpha][beta_gamma]"
23
23
  end
24
24
  end
25
+
26
+ context "dot_flatten_hash" do
27
+ it "turns a hash into dot notation" do
28
+ sample = { :user => { :name => "me" } }
29
+ result = base.send(:dot_flatten_hash, sample)
30
+ expect( result ).to eq({"user.name" => "me"})
31
+ end
32
+
33
+ it "turns a hash with array values into a hash" do
34
+ sample = { :user => { :ids => [1, 2, 3] }, :z => { :ids => [:a, :b] } }
35
+ result = base.send(:dot_flatten_hash, sample)
36
+ expect( result ).to eq({"user.ids" => [1, 2, 3], "z.ids" => [:a, :b]})
37
+ end
38
+ end
25
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandarus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duane Johnson