hash-pipe 0.0.1 → 0.0.2

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: 2726ae03f2f526feb6a99d7e9d58dcd6da86568b
4
- data.tar.gz: b2983bb6aa9033805a3468cb8f858a837980a839
3
+ metadata.gz: ddb4c5e25772c8e591f435f87d0eb18187cb9ae6
4
+ data.tar.gz: 5c09a00a7c8efaf8ade75d6e66dd6815d1fc6a4f
5
5
  SHA512:
6
- metadata.gz: 8354bf2a610ee5edb9a2b05a08480efdf534566a02b77f2400935fd3d3969de5f8a02dddb1315c4e41f0b1135eb6455b80fde1b7ae54987c6f178350d2350dbe
7
- data.tar.gz: 26ce6d96912a5139be19398c27540a3b2042710f691e4a8c9b3f467a946b5e5d77f1d946a4fecaf66b6cb31e0aab18ccc40471a41b89bf4998a433f3fb3fa4e9
6
+ metadata.gz: 9350e08d5df889ef833c5cab43c5e4cae0c92124a6e4dfcc041c7d307d5dd07c280c9df6fef1779d854e750ae9d0106c4050e13697f7747e656df0e1a8951156
7
+ data.tar.gz: 0b1c90b6c209a715217761aa5272e356fd39428bd2be60774bb67b91e0c3ce2c413e97b4b2e344d04ec34690ebf39e7e0b8aea1b4b91c7aed23ce54dd096b6e2
data/Gemfile.lock CHANGED
@@ -1,25 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hash-pipe (0.0.1)
5
- activesupport (~> 4.0)
4
+ hash-pipe (0.0.2)
5
+ activesupport (~> 4.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (4.0.3)
11
- i18n (~> 0.6, >= 0.6.4)
12
- minitest (~> 4.2)
13
- multi_json (~> 1.3)
10
+ activesupport (4.1.0)
11
+ i18n (~> 0.6, >= 0.6.9)
12
+ json (~> 1.7, >= 1.7.7)
13
+ minitest (~> 5.1)
14
14
  thread_safe (~> 0.1)
15
- tzinfo (~> 0.3.37)
16
- atomic (1.1.15)
15
+ tzinfo (~> 1.1)
17
16
  coderay (1.1.0)
18
17
  diff-lcs (1.2.5)
19
18
  i18n (0.6.9)
19
+ json (1.8.1)
20
20
  method_source (0.8.2)
21
- minitest (4.7.5)
22
- multi_json (1.8.4)
21
+ minitest (5.3.3)
23
22
  pry (0.9.12.6)
24
23
  coderay (~> 1.0)
25
24
  method_source (~> 0.8)
@@ -33,9 +32,9 @@ GEM
33
32
  diff-lcs (>= 1.1.3, < 2.0)
34
33
  rspec-mocks (2.14.4)
35
34
  slop (3.4.7)
36
- thread_safe (0.2.0)
37
- atomic (>= 1.1.7, < 2)
38
- tzinfo (0.3.38)
35
+ thread_safe (0.3.3)
36
+ tzinfo (1.1.0)
37
+ thread_safe (~> 0.1)
39
38
 
40
39
  PLATFORMS
41
40
  ruby
data/hash-pipe.gemspec CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "hash-pipe"
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
  s.authors = ["Damien Timewell"]
7
7
  s.email = ["mail@damientimewell.com"]
8
8
  s.licenses = ['MIT']
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.summary = "A small collection of useful hash extensions"
11
11
  s.description = ""
12
12
 
13
- s.add_dependency 'activesupport', '~> 4.0'
13
+ s.add_dependency 'activesupport', '~> 4.1'
14
14
 
15
15
  s.add_development_dependency "rspec", '~> 2.14'
16
16
  s.add_development_dependency "pry", '~> 0.9'
@@ -3,13 +3,14 @@ Hash.class_eval do
3
3
  def self.convert_keys(hash, method = :underscore)
4
4
  if hash.is_a?(Array)
5
5
  hash.collect {|h| convert_keys(h, method) }
6
- else
6
+ elsif hash.is_a?(Hash)
7
7
  hash_array = hash.collect do |key,value|
8
- value = value.is_a?(Hash) ? convert_keys(value, method) : value
9
- [ key.to_s.send(method), value ]
8
+ [ key.to_s.send(method), convert_keys(value, method) ]
10
9
  end
11
10
 
12
11
  Hash[hash_array]
12
+ else
13
+ hash
13
14
  end
14
15
  end
15
16
 
@@ -27,4 +27,12 @@ describe 'key_conversion' do
27
27
  Hash.convert_keys([{ 'HELLO' => 'world' }, { 'FOO' => 'bar' }]).should eq [{ 'hello' => 'world' }, { 'foo' => 'bar' }]
28
28
  end
29
29
 
30
+ it 'should convert arrays of hashes' do
31
+ { 'HELLO' => [{ 'MR' => 'world' }] }.convert_keys.should eq 'hello' => [{'mr' => 'world'}]
32
+ end
33
+
34
+ it 'should not convert values other than arrays and hashes' do
35
+ Hash.convert_keys("HELLO WORLD").should eq "HELLO WORLD"
36
+ end
37
+
30
38
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash-pipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Timewell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-03 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '4.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.14'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.14'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.9'
55
55
  description: ''
@@ -59,9 +59,9 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
63
- - .rspec
64
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
65
  - Gemfile
66
66
  - Gemfile.lock
67
67
  - README.md
@@ -82,12 +82,12 @@ require_paths:
82
82
  - lib
83
83
  required_ruby_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []