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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90c7fec799df022cab292510997f96964ce21130
4
- data.tar.gz: 7cc754bf27cee1b74e5c848ff58d1d6d63cea0af
3
+ metadata.gz: beaba855459a6d516abe08f661ea0b4391e908a0
4
+ data.tar.gz: 926f8aec91e23bddf3397319d719b9cf41c5b17f
5
5
  SHA512:
6
- metadata.gz: 83424ae89d14838c5aa17ea9691974d8c55df1ebbd63bc5b9a05afa97911ab385e09f267a9e9844d8ded1e1aacb57fcb5d013cfbf958c001c93cf3a1035f2786
7
- data.tar.gz: fe45b74b525b1a4e5c7e2b1adfe3670097fa4bcf67308ee7b8a89350f253a343c456e2f04c5c5694b57df1aba2ad9aa70b4d0b04bdfbbe65b999f789e4b429df
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', 'full_name' => 'Mike Bland',
31
+ 'name' => 'mbland',
32
+ 'full_name' => 'Mike Bland',
32
33
  'private' => {
33
- 'email' => 'michael.bland@gsa.gov', 'location' => 'DCA',
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
- => {"name"=>"mbland", "full_name"=>"Mike Bland"}
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
- => {"name"=>"mbland", "full_name"=>"Mike Bland",
57
- "email"=>"michael.bland@gsa.gov", "location"=>"DCA"}
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
- 'languages' => ['C++', 'Python'], 'full_name' => 'Michael S. Bland',
65
- 'private' => {
66
- 'location' => 'Alexandria, VA', 'previous_companies' => ['Google'],
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
- => {"name"=>"mbland", "full_name"=>"Michael S. Bland",
74
- "private"=>{
75
- "email"=>"michael.bland@gsa.gov", "location"=>"Alexandria, VA",
76
- "previous_companies"=>["Google"]},
77
- "languages"=>["C++", "Python"]}
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
- 'languages' => ['Ruby'],
81
- 'private' => {
82
- 'previous_companies' => ['Northrop Grumman'],
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
- => {"name"=>"mbland", "full_name"=>"Michael S. Bland",
90
- "private"=>{
91
- "email"=>"michael.bland@gsa.gov", "location"=>"Alexandria, VA",
92
- "previous_companies"=>["Google", "Northrop Grumman"]},
93
- "languages"=>["C++", "Python", "Ruby"]}
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
- => {"private"=>{
133
- "team"=>[
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
- "team"=>[
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
@@ -1,4 +1,7 @@
1
1
  # @author: Mike Bland (michael.bland@gsa.gov)
2
+
3
+ require 'hash-joiner/version'
4
+
2
5
  module HashJoiner
3
6
  # Recursively strips information from +collection+ matching +key+.
4
7
  #
@@ -0,0 +1,4 @@
1
+ # @author Mike Bland (michael.bland@gsa.gov)
2
+ module HashJoiner
3
+ VERSION = "0.0.6"
4
+ end
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.5
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-07 00:00:00.000000000 Z
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: