happy_hash 0.0.1 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a703785de898829d8aa39c93529ccf381dc2a5c
4
- data.tar.gz: ef388b2641fc073d5e0984b31a6c7eda86d023a1
3
+ metadata.gz: e9ce07ca09d74ae9cf85eefaf342e65829697871
4
+ data.tar.gz: 4d2a7f7f05c0beeb7165188dec570ded122a0e00
5
5
  SHA512:
6
- metadata.gz: 9e13d67a22597204d80930ca557b750c55f1bf71fbfc92dce1cee6a7e7da4cbba86c63a48d08f54893a3f8560cbc37cb73f17aba9105b17f7947a72d55fd91a8
7
- data.tar.gz: e0c278b9113dabe51681443c1defb49f5e5554cccfb5502f181948d9d09532217be6f54a06e0606179f2cc91524686f04661bdba12256c0e39d4fd99d0b5c3fc
6
+ metadata.gz: c3a6acb99180c97e827fbca503fb058f47850b984d6493d644b2308c8be33fdb0dddc3d288b0d37eaaaf5f1472a6f23e53e9c14b81c1f1c5f6a31817dc03b4c8
7
+ data.tar.gz: c91bb0f28ad130baef5714c18b21e4e406401550cd84c5e4b92454c68da2bb0a6eebf4ab2764cad8306b0366fbf636675d0482dd0a8620c14b3fdcaa6b8c3db5
data/lib/happy_hash.rb CHANGED
@@ -10,7 +10,7 @@ class Hash
10
10
  def sym_keys(hash, down_case=false)
11
11
  hash.inject({}) { |result, (key, value)|
12
12
  new_key = case key
13
- when String then (down_case ? key.downcase.to_sym : key.underscore.to_sym)
13
+ when String then (down_case ? key.to_sym : key.underscore.to_sym)
14
14
  else key
15
15
  end
16
16
  new_value = case value
@@ -0,0 +1,25 @@
1
+ require 'happy_hash'
2
+
3
+ describe Hash do
4
+ context 'Given a normal hash with string keys' do
5
+ let (:string_hash) { { 'keyA' => 'ValA' } }
6
+ it 'returns a new hash with the keys as symbols' do
7
+ string_hash.happy_hash.should == { key_a: 'ValA' }
8
+ end
9
+ end
10
+
11
+ context 'Given a normal hash with string keys' do
12
+ let (:string_hash) { { 'keyA' => 'ValA' } }
13
+ it 'will return a hash that ignores capitals, and doesnt underscore keys' do
14
+ string_hash.happy_hash(true).should == { keyA: 'ValA' }
15
+ end
16
+ end
17
+
18
+ context 'Given hashes containing arrays containing hashes' do
19
+ let(:hash) { {'keyA' => [ {'SomeKey' => 'SomeVal'}, {"AnotherKey" => "anotherVal"} ] } }
20
+ it 'will fix all hashes, not just top level ones' do
21
+ hash.happy_hash.should == { key_a: [ { some_key: 'SomeVal' }, { another_key: 'anotherVal' } ] }
22
+ end
23
+ end
24
+ end
25
+
metadata CHANGED
@@ -1,24 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happy_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronnie Howell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-29 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
- email: rhowell@tribune.com
14
+ email: ronniemhowell@gmail.com
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - lib/string.rb
20
19
  - lib/happy_hash.rb
21
- homepage: http://rubygems.org/gems/happy_hash
20
+ - lib/string.rb
21
+ - spec/happy_hash_spec.rb
22
+ homepage: https://github.com/rhowell/happy_hash
22
23
  licenses:
23
24
  - MIT
24
25
  metadata: {}
@@ -38,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
39
  version: '0'
39
40
  requirements: []
40
41
  rubyforge_project:
41
- rubygems_version: 2.1.11
42
+ rubygems_version: 2.2.1
42
43
  signing_key:
43
44
  specification_version: 4
44
45
  summary: Make your hashes happy! Converts strings to symbols, even inside arrays inside