insensitive_hash 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -42,7 +42,7 @@ ih.delete :Abc # 10
42
42
  ih.keys # ['DEF']
43
43
 
44
44
  # Hashes and Hashes in Arrays as values are automatically converted to be insensitive
45
- # (Useful for processing YAML inputs)
45
+ # (Useful when processing YAML inputs)
46
46
  ih['kids'] = { :hello => [ { :world => '!!!' } ] }
47
47
  ih[:kids]['Hello'].first['WORLD'] # !!!
48
48
  ```
@@ -2,7 +2,7 @@ require "insensitive_hash/version"
2
2
 
3
3
  class InsensitiveHash < Hash
4
4
  def initialize hash = {}
5
- @key_map = hash.keys.inject({}) { |h, k| h[encode k] = k; h }
5
+ @key_map = {}
6
6
 
7
7
  hash.each do |key, value|
8
8
  self[key] = InsensitiveHash.wrap value
@@ -1,3 +1,3 @@
1
1
  class InsensitiveHash < Hash
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -22,9 +22,6 @@ class TestInsensitiveHash < Test::Unit::TestCase
22
22
  end
23
23
  end
24
24
  end
25
-
26
- #hash = {"source db"=>{"driver"=>"com.mysql.jdbc.Driver", "url"=>"jdbc:mysql://localhost/test", "user"=>"root"}, "target db"=>{"driver"=>"com.mysql.jdbc.Driver", "url"=>"jdbc:mysql://localhost/test", "user"=>"root"}, "mappings"=>[{"table name"=>"a", "writers/partition"=>0}]}
27
- #p Marshal.load(Marshal.dump(hash)).insensitive
28
25
  end
29
26
 
30
27
  def test_has_key_set
@@ -56,6 +53,12 @@ class TestInsensitiveHash < Test::Unit::TestCase
56
53
  assert_equal 1, ih[:c].first[:x]
57
54
  assert_equal 2, ih[:c].last['Y']
58
55
 
56
+ # Deeeeeper nesting
57
+ ih['c'] = [ [ [ { 'x' => 1 }, { :y => 2 } ] ] ]
58
+ assert_equal 2, ih[:c].first.first.last[:Y]
59
+ ih['c'] = { 'a' => { 'a' => { 'a' => 100 } } }
60
+ assert_equal 100, ih[:C][:a][:A]['A']
61
+
59
62
  ih[5] = 50
60
63
  assert_equal 50, ih[5]
61
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insensitive_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-27 00:00:00.000000000Z
12
+ date: 2011-10-28 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Hash with case-insensitive, Symbol/String-indifferent key access
15
15
  email: