hash_path 0.2.0 → 0.3.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.
- data/lib/hash_path/version.rb +1 -1
- data/lib/hash_path.rb +19 -0
- metadata +39 -19
data/lib/hash_path/version.rb
CHANGED
data/lib/hash_path.rb
CHANGED
@@ -40,6 +40,25 @@ module HashPath
|
|
40
40
|
current_value
|
41
41
|
end
|
42
42
|
|
43
|
+
# Provides flattened hash key paths
|
44
|
+
def flatten_key_paths(hash_or_obj=self, prefix=nil)
|
45
|
+
case hash_or_obj
|
46
|
+
when Hash
|
47
|
+
hash_or_obj.inject({}) do |h, (k,v)|
|
48
|
+
full_prefix = [prefix, k].compact.join(".")
|
49
|
+
result = flatten_key_paths(v, full_prefix)
|
50
|
+
if Hash === result
|
51
|
+
h.merge! result
|
52
|
+
else
|
53
|
+
h[full_prefix] = result
|
54
|
+
end
|
55
|
+
h
|
56
|
+
end
|
57
|
+
else
|
58
|
+
hash_or_obj
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
43
62
|
private
|
44
63
|
def normalize_path(path)
|
45
64
|
case path
|
metadata
CHANGED
@@ -1,23 +1,33 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_path
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Daniel Neighman
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-10-10 00:00:00 Z
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description: Easy path navigation for hashes
|
15
|
-
email:
|
22
|
+
email:
|
16
23
|
- dneighman@squareup.com
|
17
24
|
executables: []
|
25
|
+
|
18
26
|
extensions: []
|
27
|
+
|
19
28
|
extra_rdoc_files: []
|
20
|
-
|
29
|
+
|
30
|
+
files:
|
21
31
|
- .gitignore
|
22
32
|
- Gemfile
|
23
33
|
- LICENSE
|
@@ -26,28 +36,38 @@ files:
|
|
26
36
|
- hash_path.gemspec
|
27
37
|
- lib/hash_path.rb
|
28
38
|
- lib/hash_path/version.rb
|
29
|
-
homepage:
|
39
|
+
homepage: ""
|
30
40
|
licenses: []
|
41
|
+
|
31
42
|
post_install_message:
|
32
43
|
rdoc_options: []
|
33
|
-
|
44
|
+
|
45
|
+
require_paths:
|
34
46
|
- lib
|
35
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
48
|
none: false
|
37
|
-
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
|
41
|
-
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
57
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
47
65
|
requirements: []
|
66
|
+
|
48
67
|
rubyforge_project:
|
49
68
|
rubygems_version: 1.8.24
|
50
69
|
signing_key:
|
51
70
|
specification_version: 3
|
52
71
|
summary: Easy path navigation for hashes. Useful in specs
|
53
72
|
test_files: []
|
73
|
+
|