re-hash 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: a86df189af830efb764480391000e3df8cb7a8ee
4
- data.tar.gz: 395cfb542fba02e7a06437c1c03725c9f83409e6
2
+ SHA256:
3
+ metadata.gz: 67da88c77ffa18765b9815a10fed2a789a9f6b76bc147fcdcdcffe13a8ede4e2
4
+ data.tar.gz: 6f3e06bdf5cb10875f85b8956d27c20891477e865e1c102ecaf63af773df1a90
5
5
  SHA512:
6
- metadata.gz: 2513661d8d0ba04d469a530dae3a62345d5368d5528178e2292af7557463685a9f17c86d3997d52945a9d4e57368ef5010cc18e4e93cfb7c6c49c999d4675456
7
- data.tar.gz: 6ee14c245ee4f33f997eba0bb12f7287176f4d291f17cde2f48643f37bc165b28ad66fd22c42f61f84642fb401a254fbef68c202dd6732479ef3918a79663809
6
+ metadata.gz: a201c3ae12d29407c23034d9f0f533c50d4b0758014e39505f1ba6cb3545638183c7982ad41c4c6b5969c289d0006850b35b2048902fd5a487d7e09db5cc52ad
7
+ data.tar.gz: 46a0b16ff2bb772873d364ff4e40bb55a332e57b2e384918c91f906aeb93dd2d46bf73b5a81e6122b6abd29e3b6c4390a1e61981cd1aa9eb6f7006f5fbdacdbc
data/README.md CHANGED
@@ -9,6 +9,7 @@ Do not be confused with Ruby's core `Hash#rehash` method. This gem has nothing t
9
9
  do with it and is used solely for mapping values from source hash into another one.
10
10
 
11
11
  [![build status](https://secure.travis-ci.org/akuzko/rehash.png)](http://travis-ci.org/akuzko/rehash)
12
+ [![github release](https://img.shields.io/github/release/akuzko/rehash.svg)](https://github.com/akuzko/rehash/releases)
12
13
 
13
14
  ## Installation
14
15
 
@@ -87,7 +88,7 @@ Rehash.map(hash) do |m|
87
88
  foos.map{ |item| Rehash.map(item, '/bar/baz' => '/value') }
88
89
  end
89
90
  end
90
- # => {:baz1 => 4, faz: 1, fak: 2, :foos => [{:value => '3-1'}, {:value => '3-2'}]}
91
+ # => {faz: 1, fak: 2, :baz1 => 4, :foos => [{:value => '3-1'}, {:value => '3-2'}]}
91
92
  ```
92
93
 
93
94
  In case if you need to do any additional manipulations over resulting returned hash,
@@ -149,7 +150,7 @@ keys. To use other options on a distinct `map` or `map_with` calls you have to u
149
150
 
150
151
  ```rb
151
152
  Rehash.map(hash, delimiter: '.', symbolize_keys: false) do |m|
152
- m.('foo.bam.baz' => 'foo.baz')
153
+ m.('foo.bar.baz' => 'foo.baz')
153
154
  )
154
155
  # => {"foo" => {"baz" => 1}}
155
156
  ```
@@ -158,7 +159,7 @@ Or you can set default options globally:
158
159
 
159
160
  ```rb
160
161
  Rehash.default_options(delimiter: '.', symbolize_keys: false)
161
- Rehash.map(hash, 'foo.bam.baz' => 'foo.baz') # => {"foo" => {"baz" => 1}}
162
+ Rehash.map(hash, 'foo.bar.baz' => 'foo.baz') # => {"foo" => {"baz" => 1}}
162
163
  ```
163
164
 
164
165
  ### Default value
data/lib/rehash/mapper.rb CHANGED
@@ -55,11 +55,11 @@ module Rehash
55
55
  return if !result
56
56
 
57
57
  with_array_access, array_key, index = with_array_access?(key)
58
-
58
+
59
59
  if with_array_access
60
- lookup(result[array_key] || result[array_key.to_sym], index)
60
+ lookup(result.key?(array_key) ? result[array_key] : result[array_key.to_sym], index)
61
61
  else
62
- result[key] || result[key.to_sym]
62
+ result.key?(key) ? result[key] : result[key.to_sym]
63
63
  end
64
64
  end
65
65
  end
@@ -85,7 +85,7 @@ module Rehash
85
85
 
86
86
  def lookup(array, index)
87
87
  return array[index.to_i] unless index =~ /^([^:]+):(.+)$/
88
-
88
+
89
89
  key, value = $1, $2
90
90
  array.find { |item| (item[key] || item[key.to_sym]) == value }
91
91
  end
@@ -1,3 +1,3 @@
1
1
  module Rehash
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/rehash.gemspec CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.12"
25
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "bundler", ">= 2.2.33"
25
+ spec.add_development_dependency "rake", ">= 12.3.3"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  spec.add_development_dependency "pry"
28
28
  spec.add_development_dependency "pry-nav"
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: re-hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Kuzko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-22 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: 2.2.33
20
20
  type: :development
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: '1.12'
26
+ version: 2.2.33
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
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
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -121,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 2.4.8
124
+ rubygems_version: 3.1.6
126
125
  signing_key:
127
126
  specification_version: 4
128
127
  summary: Easy-to-use hash values mapping and transformation.