insensitive_hash 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmNkMzgxNTY2ZGY4NTY4MWI4YTYzNGEyMDJlMjQwZDE1NGFlZDMwZg==
5
+ data.tar.gz: !binary |-
6
+ YmE3OTMxYWFmZTJmZDcyZWM4YTcwYjU3MTI4NmRiMTY4NjFjMzY3NQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZjkxNTNkMTFiZDc4ZjUxN2M2Y2EyNjZjMDIxYzY1YjY0MzFjZjg0YzJjOWEx
10
+ MjZiZTg1YWFkYzlkN2YwZmYyYTBhY2Y0ZmI2ZDg3YzgyZTBiZjVmMzc4OWY5
11
+ YTNkZjBiNWZhZjcwYjJmOTYyYTI1YWU4NzU3ODg5MTY2M2YyMjE=
12
+ data.tar.gz: !binary |-
13
+ ZmJjZGM3OWM1ODAzN2Y1OTJiYjY2MjNmZTJmYjlkZTViN2NjMTM5ODhiN2Vh
14
+ ZTNjYWVkMWQzOTgyNzgyYTViYTY4ZTgzMDRkYzVjMzkxZTMwZjgwYTQzODU5
15
+ MTkyYjhmYTczYTkxN2E3MzZiNjI2NmY4NDVmYjg0M2RkNjc0NGY=
@@ -21,7 +21,7 @@ class InsensitiveHash < Hash
21
21
  def initialize default = nil, &block
22
22
  if block_given?
23
23
  raise ArgumentError.new('wrong number of arguments') unless default.nil?
24
- super &block
24
+ super(&block)
25
25
  else
26
26
  super
27
27
  end
@@ -53,7 +53,7 @@ class InsensitiveHash < Hash
53
53
  clear
54
54
  @encoder = prc
55
55
  kvs.each do |pair|
56
- store *pair
56
+ store(*pair)
57
57
  end
58
58
 
59
59
  prc
@@ -69,7 +69,7 @@ class InsensitiveHash < Hash
69
69
  # @see http://www.ruby-doc.org/core-1.9.3/Hash.html Hash
70
70
  def self.[] *init
71
71
  h = Hash[*init]
72
- InsensitiveHash.new.tap do |ih|
72
+ self.new.tap do |ih|
73
73
  ih.merge_recursive! h
74
74
  end
75
75
  end
@@ -103,7 +103,7 @@ class InsensitiveHash < Hash
103
103
 
104
104
  # @see http://www.ruby-doc.org/core-1.9.3/Hash.html Hash
105
105
  def merge other_hash
106
- InsensitiveHash.new.tap do |ih|
106
+ self.class.new.tap do |ih|
107
107
  ih.replace self
108
108
  ih.merge! other_hash
109
109
  end
@@ -162,7 +162,7 @@ class InsensitiveHash < Hash
162
162
  # @see http://www.ruby-doc.org/core-1.9.3/Hash.html Hash
163
163
  def fetch *args, &block
164
164
  args[0] = lookup_key(args[0]) if args.first
165
- super *args, &block
165
+ super(*args, &block)
166
166
  end
167
167
 
168
168
  # @see http://www.ruby-doc.org/core-1.9.3/Hash.html Hash
@@ -187,13 +187,13 @@ private
187
187
 
188
188
  def wrap value
189
189
  case value
190
- when InsensitiveHash
190
+ when InsensitiveHash, self.class
191
191
  value.tap { |ih|
192
192
  ih.safe = safe?
193
193
  ih.encoder = encoder
194
194
  }
195
195
  when Hash
196
- InsensitiveHash.new.tap { |ih|
196
+ self.class.new.tap { |ih|
197
197
  ih.safe = safe?
198
198
  ih.encoder = encoder
199
199
  ih.merge_recursive!(value)
@@ -1,3 +1,3 @@
1
1
  class InsensitiveHash < Hash
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -1,3 +1,4 @@
1
+ $VERBOSE = true
1
2
  require 'rubygems'
2
3
  require 'bundler'
3
4
  Bundler.setup(:default, :development)
@@ -620,5 +621,13 @@ class TestInsensitiveHash < Test::Unit::TestCase
620
621
  assert_equal :d, ih[:any][:any][:any]
621
622
  end
622
623
  end
623
- end
624
624
 
625
+ class MyInsensitiveHash < InsensitiveHash
626
+ end
627
+
628
+ def test_subclassing
629
+ mih = MyInsensitiveHash[{ "a" => { "b" => 3 } }]
630
+ assert_instance_of MyInsensitiveHash, mih
631
+ assert_instance_of MyInsensitiveHash, mih["a"]
632
+ end
633
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insensitive_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 0.3.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Junegunn Choi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
11
+ date: 2013-09-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: test-unit
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -48,28 +45,26 @@ files:
48
45
  - test/test_insensitive_hash.rb
49
46
  homepage: https://github.com/junegunn/insensitive_hash
50
47
  licenses: []
48
+ metadata: {}
51
49
  post_install_message:
52
50
  rdoc_options: []
53
51
  require_paths:
54
52
  - lib
55
53
  required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
54
  requirements:
58
55
  - - ! '>='
59
56
  - !ruby/object:Gem::Version
60
57
  version: '0'
61
58
  required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
59
  requirements:
64
60
  - - ! '>='
65
61
  - !ruby/object:Gem::Version
66
62
  version: '0'
67
63
  requirements: []
68
64
  rubyforge_project: insensitive_hash
69
- rubygems_version: 1.8.24
65
+ rubygems_version: 2.0.7
70
66
  signing_key:
71
- specification_version: 3
67
+ specification_version: 4
72
68
  summary: Case-insensitive Ruby Hash
73
69
  test_files:
74
70
  - test/test_insensitive_hash.rb
75
- has_rdoc: