iron-extensions 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.1.5 / 2014-03-31
2
+
3
+ * Fix bug in Enumerable#convert_to_hash where default values (eg hashes) weren't being duplicated
4
+
1
5
  == 1.1.4 / 2014-01-14
2
6
 
3
7
  * Add Enumerable#delete_unless
data/Version.txt CHANGED
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.1.5
@@ -5,7 +5,7 @@ module Enumerable
5
5
  def convert_to_hash(init_val = nil)
6
6
  hash = {}
7
7
  self.each do |key|
8
- hash[key] = block_given? ? yield(key) : init_val
8
+ hash[key] = block_given? ? yield(key) : (init_val.dup rescue init_val)
9
9
  end
10
10
  hash
11
11
  end
@@ -9,6 +9,12 @@ describe Enumerable do
9
9
  [:a, :b].convert_to_hash(false).should == {:a => false, :b => false}
10
10
  end
11
11
 
12
+ it 'should duplicate default hash values' do
13
+ h = [1,2,3].convert_to_hash({})
14
+ h[1][:foo] = 5
15
+ h[2][:foo].should be_nil
16
+ end
17
+
12
18
  it 'should accept a block to set hash values' do
13
19
  [:a, :b, :c].convert_to_hash {|k| k.to_s.upcase}.should == {:a => 'A', :b => 'B', :c => 'C'}
14
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
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: 2014-01-14 00:00:00.000000000 Z
12
+ date: 2014-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec