hash-joiner 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -26
- data/lib/hash-joiner.rb +3 -0
- data/lib/hash-joiner/version.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beaba855459a6d516abe08f661ea0b4391e908a0
|
4
|
+
data.tar.gz: 926f8aec91e23bddf3397319d719b9cf41c5b17f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c0997705bd473649288db3848e3541bc325f6e730afadc2de64f30a0c8cf08f8c2a1c7399e9366506ce140edbcba81544fbe0683d1209f08daa6a3fb00022d3
|
7
|
+
data.tar.gz: 3a915d2f10407ed68e4f04a45fc3b3a3dd926ffca08edc928f05075e2e0c071c5b78f69c366a6abd93109da6bf809ad8289c18e2d76779905e8d94f17434deff
|
data/README.md
CHANGED
@@ -28,9 +28,11 @@ The typical use case is to have a YAML file containing both public and private d
|
|
28
28
|
```ruby
|
29
29
|
> require 'hash-joiner'
|
30
30
|
> my_data_collection = {
|
31
|
-
'name' => 'mbland',
|
31
|
+
'name' => 'mbland',
|
32
|
+
'full_name' => 'Mike Bland',
|
32
33
|
'private' => {
|
33
|
-
'email' => 'michael.bland@gsa.gov',
|
34
|
+
'email' => 'michael.bland@gsa.gov',
|
35
|
+
'location' => 'DCA',
|
34
36
|
},
|
35
37
|
}
|
36
38
|
```
|
@@ -42,7 +44,10 @@ The following examples, except for **Join an Array of Hash values**, all begin w
|
|
42
44
|
```ruby
|
43
45
|
# Everything within the `private:` property will be deleted.
|
44
46
|
> HashJoiner.remove_data my_data_collection, "private"
|
45
|
-
=> {
|
47
|
+
=> {
|
48
|
+
"name"=>"mbland",
|
49
|
+
"full_name"=>"Mike Bland",
|
50
|
+
}
|
46
51
|
```
|
47
52
|
|
48
53
|
#### Promote private data
|
@@ -53,44 +58,62 @@ This will render `private:` data at the same level as other, nonprivate data:
|
|
53
58
|
# Everything within the `private:` property will be
|
54
59
|
# promoted up one level.
|
55
60
|
> HashJoiner.promote_data my_data_collection, "private"
|
56
|
-
=> {
|
57
|
-
|
61
|
+
=> {
|
62
|
+
"name"=>"mbland",
|
63
|
+
"full_name"=>"Mike Bland",
|
64
|
+
"email"=>"michael.bland@gsa.gov",
|
65
|
+
"location"=>"DCA",
|
66
|
+
}
|
58
67
|
```
|
59
68
|
|
60
69
|
#### Perform a deep merge with other Hash values
|
61
70
|
|
62
71
|
```ruby
|
63
72
|
> extra_info = {
|
64
|
-
|
65
|
-
|
66
|
-
|
73
|
+
"languages" => ["C++", "Python"],
|
74
|
+
"full_name" => "Michael S. Bland",
|
75
|
+
"private" => {
|
76
|
+
"location" => "Alexandria, VA",
|
77
|
+
"previous_companies" => ["Google"],
|
67
78
|
},
|
68
79
|
}
|
69
80
|
|
70
81
|
# The original Hash will have information added for
|
71
82
|
# `full_name`, `languages', and `private => location`.
|
83
|
+
|
72
84
|
> HashJoiner.deep_merge my_data_collection, extra_info
|
73
|
-
=> {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
85
|
+
=> {
|
86
|
+
"name"=>"mbland",
|
87
|
+
"full_name"=>"Michael S. Bland",
|
88
|
+
"languages"=>["C++", "Python"],
|
89
|
+
"private"=> {
|
90
|
+
"email"=>"michael.bland@gsa.gov",
|
91
|
+
"location"=>"Alexandria, VA",
|
92
|
+
"previous_companies"=>["Google"],
|
93
|
+
},
|
94
|
+
}
|
78
95
|
|
79
96
|
> extra_info = {
|
80
|
-
|
81
|
-
|
82
|
-
|
97
|
+
"languages" => ["Ruby"],
|
98
|
+
"private" => {
|
99
|
+
"previous_companies" => ["Northrop Grumman"],
|
83
100
|
},
|
84
101
|
}
|
85
102
|
|
86
103
|
# The Hash will now have added information for
|
87
104
|
# `languages` and `private => previous_companies`.
|
105
|
+
|
88
106
|
> HashJoiner.deep_merge my_data_collection, extra_info
|
89
|
-
=> {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
107
|
+
=> {
|
108
|
+
"name"=>"mbland",
|
109
|
+
"full_name"=>"Michael S. Bland",
|
110
|
+
"languages"=>["C++", "Python", "Ruby"],
|
111
|
+
"private"=> {
|
112
|
+
"email"=>"michael.bland@gsa.gov",
|
113
|
+
"location"=>"Alexandria, VA",
|
114
|
+
"previous_companies"=>["Google", "Northrop Grumman"],
|
115
|
+
},
|
116
|
+
}
|
94
117
|
```
|
95
118
|
|
96
119
|
#### Join an Array of Hash values
|
@@ -129,15 +152,20 @@ This corresponds to the process of joining different collections of Jekyll-impor
|
|
129
152
|
#
|
130
153
|
# `site.data['private']` can now be safely discarded.
|
131
154
|
> HashJoiner.join_data 'team', 'name', site.data, site.data['private']
|
132
|
-
=> {
|
133
|
-
|
155
|
+
=> {
|
156
|
+
"private"=>{
|
157
|
+
"team"=>[
|
134
158
|
{"name"=>"mbland", "languages"=>["Python", "Ruby"]},
|
135
159
|
{"name"=>"foobar", "email"=>"foo.bar@gsa.gov"},
|
136
|
-
{"name"=>"bazquux", "email"=>"baz.quux@gsa.gov"}
|
137
|
-
|
160
|
+
{"name"=>"bazquux", "email"=>"baz.quux@gsa.gov"}
|
161
|
+
]
|
162
|
+
},
|
163
|
+
"team"=>[
|
138
164
|
{"name"=>"mbland", "languages"=>["C++", "Python", "Ruby"]},
|
139
165
|
{"name"=>"foobar", "full_name"=>"Foo Bar", "email"=>"foo.bar@gsa.gov"},
|
140
|
-
{"name"=>"bazquux", "email"=>"baz.quux@gsa.gov"}
|
166
|
+
{"name"=>"bazquux", "email"=>"baz.quux@gsa.gov"}
|
167
|
+
]
|
168
|
+
}
|
141
169
|
```
|
142
170
|
|
143
171
|
#### Running `filter-yaml-files`
|
data/lib/hash-joiner.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash-joiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Bland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: safe_yaml
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- README.md
|
93
93
|
- bin/filter-yaml-files
|
94
94
|
- lib/hash-joiner.rb
|
95
|
+
- lib/hash-joiner/version.rb
|
95
96
|
homepage: https://github.com/18F/hash-joiner
|
96
97
|
licenses:
|
97
98
|
- CC0
|
@@ -117,3 +118,4 @@ signing_key:
|
|
117
118
|
specification_version: 4
|
118
119
|
summary: Module for pruning, promoting, deep-merging, and joining Hash data
|
119
120
|
test_files: []
|
121
|
+
has_rdoc:
|