hash_kit 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd1854ab32177bfb5bfb111376bded67090f1f42
4
- data.tar.gz: 685bb9ecb6ae641d6fe37f7cd0d84fb2d69435b1
3
+ metadata.gz: cbfcb56f129d09473358ec32ebe9df25f4509345
4
+ data.tar.gz: 7e4be22e348d2685448e078283cca6dbc6c2348d
5
5
  SHA512:
6
- metadata.gz: f03701b0871d9029401fc734c4116a2c1e7e003b5610204c9a19c587deadf8acdb1ba1c10d794c280602c285513af052e2da0f7d7c48dd14575dc4c8e9ab23b7
7
- data.tar.gz: a2710a1c61c6f330047f8ae5dfd222bde0d0a957b39f447cea16af4265b30750f35c504c61c2ebca244b29dc61d22ab936fea4d4c2df4f2908be54733a86da43
6
+ metadata.gz: b2f9d165d696ec7614f426ad94547f968e1fde87c9135b080dc11b1063598bd84f09ea59bd070533afd2c06feb24650ece5cfb6ed713c215b9126369431e8a6c
7
+ data.tar.gz: 6dae70e009933b127cdc641a01c1e91567003f72031f41d800f4f0ab7aad88b01c2dc769ef0781d9faafe785deaad5712cbc34bbd4708c39952239638f0d5cc8
@@ -4,18 +4,36 @@ module HashKit
4
4
  #This method is called to convert all the keys of a hash into symbols to allow consistent usage of hashes within your Ruby application.
5
5
  def symbolize(hash)
6
6
  {}.tap do |h|
7
- hash.each { |key, value| h[key.to_sym] = map_value(value) }
7
+ hash.each { |key, value| h[key.to_sym] = map_value_symbol(value) }
8
+ end
9
+ end
10
+
11
+ #This method is called to convert all the keys of a hash into strings to allow consistent usage of hashes within your Ruby application.
12
+ def stringify(hash)
13
+ {}.tap do |h|
14
+ hash.each { |key, value| h[key.to_s] = map_value_string(value) }
8
15
  end
9
16
  end
10
17
 
11
18
  private
12
19
 
13
- def map_value(thing)
20
+ def map_value_symbol(thing)
14
21
  case thing
15
22
  when Hash
16
23
  symbolize(thing)
17
24
  when Array
18
- thing.map { |v| map_value(v) }
25
+ thing.map { |v| map_value_symbol(v) }
26
+ else
27
+ thing
28
+ end
29
+ end
30
+
31
+ def map_value_string(thing)
32
+ case thing
33
+ when Hash
34
+ stringify(thing)
35
+ when Array
36
+ thing.map { |v| map_value_string(v) }
19
37
  else
20
38
  thing
21
39
  end
@@ -1,3 +1,3 @@
1
1
  module HashKit
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler