kim 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -18,6 +18,10 @@ Provide multiple keys and it will tell you if they are contained in the current
18
18
 
19
19
  Finds a value taking nesting into account
20
20
 
21
+ ### select_keys
22
+
23
+ Receive a list of keys and return a hash subset containing the keys specified
24
+
21
25
  Fixnum
22
26
  ------
23
27
 
data/README.md CHANGED
@@ -18,6 +18,10 @@ Provide multiple keys and it will tell you if they are contained in the current
18
18
 
19
19
  Finds a value taking nesting into account
20
20
 
21
+ ### select_keys
22
+
23
+ Receive a list of keys and return a hash subset containing the keys specified
24
+
21
25
  Fixnum
22
26
  ------
23
27
 
data/lib/kim/hash.rb CHANGED
@@ -24,6 +24,10 @@ module Kim
24
24
  def deep_value *keys
25
25
  keys.count <= 1 ? self[keys.first] : self[keys.shift].deep_value(*keys) rescue nil
26
26
  end
27
+
28
+ def select_keys *keys
29
+ reject{ |k,v| ! keys.include? k }
30
+ end
27
31
  end
28
32
  end
29
33
 
data/lib/kim/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kim
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -12,4 +12,8 @@ describe "Hash Additions" do
12
12
  it "should merge a key only exists in other" do
13
13
  {:a => {:aa => :c}}.deep_merge({:a=> {:ab => :c}, :b => {:ba => :c}}).should == {:a=> {:aa => :c, :ab => :c}, :b => {:ba => :c}}
14
14
  end
15
+
16
+ it "should select keys from a hash, returning a new hash containing those keys" do
17
+ {:a => 1, :b => 2, :c => 3, :d => 4}.select_keys(:a,:b).should == {:a => 1, :b => 2}
18
+ end
15
19
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kim
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 10
10
- version: 0.0.10
9
+ - 11
10
+ version: 0.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Giancarlo Palavicini
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-06 00:00:00 Z
18
+ date: 2011-10-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec