hashie 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.4
4
+
5
+ * make #fetch method consistent with normal Hash markiz #94
6
+ * various doc tweaks craiglittle #90
7
+
3
8
  ## 2.0.3
4
9
 
5
10
  * Hashie::Mash.new(abc: true).respond_to?(:abc?) works 7even #88
@@ -1,6 +1,3 @@
1
- **Note:** This documentation is for the unreleased version 2.0 of
2
- Hashie. See the [1-1-stable branch](https://github.com/intridea/hashie/tree/1-1-stable) for documentation of the released version.
3
-
4
1
  # Hashie [![Build Status](https://secure.travis-ci.org/intridea/hashie.png)](http://travis-ci.org/intridea/hashie) [![Dependency Status](https://gemnasium.com/intridea/hashie.png)](https://gemnasium.com/intridea/hashie)
5
2
 
6
3
  Hashie is a growing collection of tools that extend Hashes and make
@@ -14,11 +11,10 @@ Hashie is available as a RubyGem:
14
11
 
15
12
  ## Hash Extensions
16
13
 
17
- New to version 2.0 of Hashie, the library has been broken up into a
18
- number of atomically includeable Hash extension modules as described
19
- below. This provides maximum flexibility for users to mix and match
20
- functionality while maintaining feature parity with earlier versions of
21
- Hashie.
14
+ The library is broken up into a number of atomically includeable Hash
15
+ extension modules as described below. This provides maximum flexibility
16
+ for users to mix and match functionality while maintaining feature parity
17
+ with earlier versions of Hashie.
22
18
 
23
19
  Any of the extensions listed below can be mixed into a class by
24
20
  `include`-ing `Hashie::Extensions::ExtensionName`.
@@ -237,4 +233,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)
237
233
 
238
234
  ## Copyright
239
235
 
240
- Copyright (c) 2009-2011 Intridea, Inc. (http://intridea.com/). See LICENSE for details.
236
+ Copyright (c) 2009-2013 Intridea, Inc. (http://intridea.com/). See LICENSE for details.
@@ -114,8 +114,8 @@ module Hashie
114
114
  end
115
115
  end
116
116
 
117
- def fetch(key, default_value = nil)
118
- self[key] || block_given? && yield(key) || default_value || super(key)
117
+ def fetch(key, *args)
118
+ super(convert_key(key), *args)
119
119
  end
120
120
 
121
121
  def delete(key)
@@ -1,3 +1,3 @@
1
1
  module Hashie
2
- VERSION = '2.0.3'
2
+ VERSION = '2.0.4'
3
3
  end
@@ -297,19 +297,19 @@ describe Hashie::Mash do
297
297
  it 'should respond to a set key' do
298
298
  Hashie::Mash.new(:abc => 'def').should be_respond_to(:abc)
299
299
  end
300
-
300
+
301
301
  it 'should respond to a set key with a suffix' do
302
302
  %w(= ? ! _).each do |suffix|
303
303
  Hashie::Mash.new(:abc => 'def').should be_respond_to(:"abc#{suffix}")
304
304
  end
305
305
  end
306
-
306
+
307
307
  it 'should respond to an unknown key with a suffix' do
308
308
  %w(= ? ! _).each do |suffix|
309
309
  Hashie::Mash.new(:abc => 'def').should be_respond_to(:"xyz#{suffix}")
310
310
  end
311
311
  end
312
-
312
+
313
313
  it "should not respond to an unknown key without a suffix" do
314
314
  Hashie::Mash.new(:abc => 'def').should_not be_respond_to(:xyz)
315
315
  end
@@ -365,7 +365,7 @@ describe Hashie::Mash do
365
365
  end
366
366
 
367
367
  describe "#fetch" do
368
- let(:hash) { {:one => 1} }
368
+ let(:hash) { {:one => 1, :other => false} }
369
369
  let(:mash) { Hashie::Mash.new(hash) }
370
370
 
371
371
  context "when key exists" do
@@ -373,6 +373,10 @@ describe Hashie::Mash do
373
373
  mash.fetch(:one).should eql(1)
374
374
  end
375
375
 
376
+ it "returns the value even if the value is falsy" do
377
+ mash.fetch(:other).should eql(false)
378
+ end
379
+
376
380
  context "when key has other than original but acceptable type" do
377
381
  it "returns the value" do
378
382
  mash.fetch('one').should eql(1)
@@ -390,6 +394,10 @@ describe Hashie::Mash do
390
394
  it "returns default value" do
391
395
  mash.fetch(:two, 8).should eql(8)
392
396
  end
397
+
398
+ it "returns default value even if it is falsy" do
399
+ mash.fetch(:two, false).should eql(false)
400
+ end
393
401
  end
394
402
 
395
403
  context "with block given" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashie
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-18 00:00:00.000000000 Z
13
+ date: 2013-04-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -157,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  segments:
159
159
  - 0
160
- hash: -486186307453190267
160
+ hash: 2159890714195675822
161
161
  required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  none: false
163
163
  requirements:
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  segments:
168
168
  - 0
169
- hash: -486186307453190267
169
+ hash: 2159890714195675822
170
170
  requirements: []
171
171
  rubyforge_project:
172
172
  rubygems_version: 1.8.23