structure_flatter 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +26 -0
- data/.rspec +2 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/lib/structure_flatter.rb +6 -0
- data/lib/structure_flatter/array_hash_structure.rb +70 -0
- data/lib/structure_flatter/version.rb +3 -0
- data/spec/inputs/various_key_value_pairs.rb +22 -0
- data/spec/inputs/various_structures.rb +160 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/structure_flatter/array_hash_structure_spec.rb +98 -0
- data/structure_flatter.gemspec +26 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGMxNDUwZmQ4ZDdjMzBlZWU2M2ZlOWZkMWIwOWNiNGY2YTIxZjdmNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWZhMzJmYjU4ZTVkMTFhYjU3M2UxNzc4NDUyNzI5NWI0NTA5ZjczNw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmRjYjY4NjgwOWI5MTE0NWFjZTdlODRiMDczM2I1YTdhZmIxMzQ4ODMwYjgz
|
10
|
+
YjlkOGNmY2ExZmU0ZmRhOTMyYWMwMzMwZDFiYjYyZjJiNmY1MzliNTRhN2Uw
|
11
|
+
ZjkyYWI5MzA2NTUyODE4ZmRiNDdjZWE5NTZmZGVlNDMwN2RiOTg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NmI1ZmJkMTdhY2ZkOWM2MjY4M2UwYjQ3YTA5OWNlNDMwYjRhNTU4MGMzYzE5
|
14
|
+
NDdjMGU4NzA3Yzk3YTZiNDc0NzEzOGI4MDljNTNkZDk5YTRhNjUxNmY2ZDgw
|
15
|
+
ZDg0MjU5MzJkOGY0NDczZDYzNDVhY2YxYWEyZTlkNTBlNDY3N2E=
|
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
|
19
|
+
# Ignore RubyMine's .idea directory
|
20
|
+
/.idea/*
|
21
|
+
|
22
|
+
# Ignore Aptana's .project file
|
23
|
+
/.project
|
24
|
+
|
25
|
+
# Ignoring .rvmrc
|
26
|
+
/.rvmrc
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 G580 mgoyal
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# StructureFlatter
|
2
|
+
|
3
|
+
When transforming data from one format to another, sometimes we end up with structures that have redundant information or a sub-optimal structure.
|
4
|
+
One type of such structure is an array of hash tables where the hash table has a redundant root element that is the singular version of the attribute on the parent object.
|
5
|
+
|
6
|
+
For example,
|
7
|
+
|
8
|
+
|
9
|
+
{
|
10
|
+
attribute_one: "foo",
|
11
|
+
cars: [
|
12
|
+
{ car: { name: "c1", content: "car one" } },
|
13
|
+
{ car: { name: "c2", content: "car two" } },
|
14
|
+
{ car: { name: "c3", content: "car three" } }
|
15
|
+
]
|
16
|
+
}
|
17
|
+
|
18
|
+
The "structure_flatter" library flattens all occurrences of the above type of structure from a given array or hash consisting of other hashes, arrays or attributes to arbitrary depth and complexity.
|
19
|
+
|
20
|
+
The result of providing the above example will be:
|
21
|
+
|
22
|
+
{
|
23
|
+
attribute_one: "foo",
|
24
|
+
cars: [
|
25
|
+
{ name: "c1", content: "car one" },
|
26
|
+
{ name: "c2", content: "car two" },
|
27
|
+
{ name: "c3", content: "car three" }
|
28
|
+
]
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
## Installation
|
33
|
+
|
34
|
+
Add this line to your application's Gemfile:
|
35
|
+
|
36
|
+
gem 'structure_flatter'
|
37
|
+
|
38
|
+
And then execute:
|
39
|
+
|
40
|
+
$ bundle
|
41
|
+
|
42
|
+
Or install it yourself as:
|
43
|
+
|
44
|
+
$ gem install structure_flatter
|
45
|
+
|
46
|
+
## Usage
|
47
|
+
|
48
|
+
Let str holds an array-hash structure that is to be flattened
|
49
|
+
|
50
|
+
str = an_array_hash_structure_to_be_flatten
|
51
|
+
|
52
|
+
Use flatten_structure! method of ArrayHashStructure class to flatten the structure
|
53
|
+
|
54
|
+
require 'structure_flatter'
|
55
|
+
|
56
|
+
flattened_str = StructureFlatter::ArrayHashStructure.new(str).flatten_structure!
|
57
|
+
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'active_support/core_ext/string'
|
2
|
+
|
3
|
+
module StructureFlatter
|
4
|
+
class ArrayHashStructure
|
5
|
+
|
6
|
+
# initializing element
|
7
|
+
# passed structure should be a simple or complex structure comprising Hashes and Arrays
|
8
|
+
def initialize(array_hash_structure = nil)
|
9
|
+
@array_hash_structure = array_hash_structure
|
10
|
+
end
|
11
|
+
|
12
|
+
# it flattens the given structure
|
13
|
+
def flatten_structure!(array_hash_structure = @array_hash_structure)
|
14
|
+
case array_hash_structure
|
15
|
+
when Array
|
16
|
+
array_hash_structure.each do |array_element|
|
17
|
+
flatten_structure!(array_element) if ((array_element.class == Array) || (array_element.class == Hash))
|
18
|
+
end
|
19
|
+
when Hash
|
20
|
+
array_hash_structure.each do |hash_key, hash_value|
|
21
|
+
if hash_value.class == Array
|
22
|
+
# trying to flatten the value
|
23
|
+
ArrayHashStructure.flatten_key_value_pair!(hash_key, hash_value)
|
24
|
+
# recursive call
|
25
|
+
flatten_structure!(hash_value)
|
26
|
+
elsif hash_value.class == Hash
|
27
|
+
hash_value.each do |hash_value_key, hash_value_value|
|
28
|
+
# recursive call
|
29
|
+
flatten_structure!(hash_value_value)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
# do nothing
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
# do nothing
|
37
|
+
end
|
38
|
+
return array_hash_structure
|
39
|
+
end
|
40
|
+
|
41
|
+
# it tries to flatten the given key value pair
|
42
|
+
def self.flatten_key_value_pair!(key, value)
|
43
|
+
if self.is_key_value_pair_flattable?(key, value)
|
44
|
+
value.each_index do |index|
|
45
|
+
value[index] = value[index].values.first
|
46
|
+
end
|
47
|
+
end
|
48
|
+
return [key, value]
|
49
|
+
end
|
50
|
+
|
51
|
+
# check if given key value pair is flattable
|
52
|
+
def self.is_key_value_pair_flattable?(key, value)
|
53
|
+
# key should be plural
|
54
|
+
return false unless key.to_s.pluralize == key.to_s
|
55
|
+
# value should be Array
|
56
|
+
return false unless value.class == Array
|
57
|
+
# checking each element of value (which is Array)
|
58
|
+
value.each do |value_element|
|
59
|
+
# should be hash
|
60
|
+
return false unless value_element.class == Hash
|
61
|
+
# it should have only one key-value pair
|
62
|
+
return false unless value_element.count == 1
|
63
|
+
# its key should be singular form of original key
|
64
|
+
return false unless (value_element.keys.first.to_s != key.to_s) && (value_element.keys[0].to_s.pluralize == key.to_s)
|
65
|
+
end
|
66
|
+
return true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module VariousKeyValuePairs
|
2
|
+
|
3
|
+
def key_value_pair_1
|
4
|
+
key = :posts
|
5
|
+
value = [
|
6
|
+
{post: {name: 'p1', content: 'post one'}},
|
7
|
+
{post: {name: 'p2', content: 'post two'}},
|
8
|
+
{post: {name: 'p3', content: 'post three'}}
|
9
|
+
]
|
10
|
+
return [key, value]
|
11
|
+
end
|
12
|
+
|
13
|
+
def key_value_pair_1_result
|
14
|
+
key = :posts
|
15
|
+
value = [
|
16
|
+
{name: 'p1', content: 'post one'},
|
17
|
+
{name: 'p2', content: 'post two'},
|
18
|
+
{name: 'p3', content: 'post three'}
|
19
|
+
]
|
20
|
+
return [key, value]
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
module VariousStructures
|
2
|
+
|
3
|
+
def nil_structure
|
4
|
+
nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def empty_hash_structure
|
8
|
+
{}
|
9
|
+
end
|
10
|
+
|
11
|
+
def empty_array_structure
|
12
|
+
[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def very_simple_hash_structure
|
16
|
+
{:key1 => :value1, :key2 => :value2, :key => :value3}
|
17
|
+
end
|
18
|
+
|
19
|
+
def very_simple_array_structure
|
20
|
+
%w(value1, value2, value3)
|
21
|
+
end
|
22
|
+
|
23
|
+
def simple_hash_structure
|
24
|
+
{
|
25
|
+
posts: [
|
26
|
+
{post: {name: 'p1', content: 'post one'}},
|
27
|
+
{post: {name: 'p2', content: 'post two'}},
|
28
|
+
{post: {name: 'p3', content: 'post three'}}
|
29
|
+
]
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def simple_hash_structure_result
|
34
|
+
{
|
35
|
+
posts: [
|
36
|
+
{name: 'p1', content: 'post one'},
|
37
|
+
{name: 'p2', content: 'post two'},
|
38
|
+
{name: 'p3', content: 'post three'}
|
39
|
+
]
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def complex_hash_structure
|
44
|
+
{
|
45
|
+
attribute_one: 'foo',
|
46
|
+
posts: [
|
47
|
+
{post: {name: 'p1', content: 'post one'}},
|
48
|
+
{post: {name: 'p2', content: 'post two'}},
|
49
|
+
{post: {name: 'p3', content: 'post three'}}
|
50
|
+
]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def complex_hash_structure_result
|
55
|
+
{
|
56
|
+
attribute_one: 'foo',
|
57
|
+
posts: [
|
58
|
+
{name: 'p1', content: 'post one'},
|
59
|
+
{name: 'p2', content: 'post two'},
|
60
|
+
{name: 'p3', content: 'post three'}
|
61
|
+
]
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def complex_hash_with_mixed_string_and_keys_structure
|
66
|
+
{
|
67
|
+
:attribute_one => 'foo',
|
68
|
+
posts: [
|
69
|
+
{'post' => {'name' => 'p1', content: 'post one'}},
|
70
|
+
{:post => {name: 'p2', content: 'post two'}},
|
71
|
+
{post: {name: 'p3', content: 'post three'}}
|
72
|
+
]
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def complex_hash_with_mixed_string_and_keys_structure_result
|
77
|
+
{
|
78
|
+
attribute_one: 'foo',
|
79
|
+
posts: [
|
80
|
+
{'name' => 'p1', content: 'post one'},
|
81
|
+
{name: 'p2', content: 'post two'},
|
82
|
+
{name: 'p3', content: 'post three'}
|
83
|
+
]
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
def complex_array_structure
|
88
|
+
['first_element',
|
89
|
+
{
|
90
|
+
attribute_one: 'foo',
|
91
|
+
cars: [
|
92
|
+
{car: {name: 'p1', content: 'car one'}},
|
93
|
+
{car: {name: 'p2', content: 'car two'}},
|
94
|
+
{car: {name: 'p3', content: 'car three'}}
|
95
|
+
]
|
96
|
+
}]
|
97
|
+
end
|
98
|
+
|
99
|
+
def complex_array_structure_result
|
100
|
+
['first_element',
|
101
|
+
{
|
102
|
+
attribute_one: 'foo',
|
103
|
+
cars: [
|
104
|
+
{name: 'p1', content: 'car one'},
|
105
|
+
{name: 'p2', content: 'car two'},
|
106
|
+
{name: 'p3', content: 'car three'}
|
107
|
+
]
|
108
|
+
}]
|
109
|
+
end
|
110
|
+
|
111
|
+
def complex_nested_structure
|
112
|
+
{
|
113
|
+
attribute_one: 'foo',
|
114
|
+
posts: [
|
115
|
+
{post: {name: 'p1', content: 'post one'}},
|
116
|
+
{post: {name: 'p2', content: 'post two'}},
|
117
|
+
{post: {name: 'p3', content: 'post three'}}
|
118
|
+
],
|
119
|
+
cars: [
|
120
|
+
{car: {name: 'p1', content: 'car one'}},
|
121
|
+
{car: {name: 'p2', content: 'car two'}},
|
122
|
+
{car: {name: 'p3', content: 'car three'}}
|
123
|
+
],
|
124
|
+
attribute_three: [1, 2,
|
125
|
+
{
|
126
|
+
attribute_one: 'foo',
|
127
|
+
cars: [
|
128
|
+
{car: {name: 'p1', content: 'car one'}},
|
129
|
+
{car: {name: 'p2', content: 'car two'}},
|
130
|
+
{car: {name: 'p3', content: 'car three'}}
|
131
|
+
]
|
132
|
+
}]
|
133
|
+
}
|
134
|
+
end
|
135
|
+
|
136
|
+
def complex_nested_structure_result
|
137
|
+
{
|
138
|
+
attribute_one: 'foo',
|
139
|
+
posts: [
|
140
|
+
{name: 'p1', content: 'post one'},
|
141
|
+
{name: 'p2', content: 'post two'},
|
142
|
+
{name: 'p3', content: 'post three'}
|
143
|
+
],
|
144
|
+
cars: [
|
145
|
+
{name: 'p1', content: 'car one'},
|
146
|
+
{name: 'p2', content: 'car two'},
|
147
|
+
{name: 'p3', content: 'car three'}
|
148
|
+
],
|
149
|
+
attribute_three: [1, 2,
|
150
|
+
{
|
151
|
+
attribute_one: 'foo',
|
152
|
+
cars: [
|
153
|
+
{name: 'p1', content: 'car one'},
|
154
|
+
{name: 'p2', content: 'car two'},
|
155
|
+
{name: 'p3', content: 'car three'}
|
156
|
+
]
|
157
|
+
}]
|
158
|
+
}
|
159
|
+
end
|
160
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
module StructureFlatter
|
4
|
+
describe ArrayHashStructure do # EXAMPLE GROUP
|
5
|
+
|
6
|
+
include VariousKeyValuePairs
|
7
|
+
include VariousStructures
|
8
|
+
|
9
|
+
describe '.is_root_flattable?' do
|
10
|
+
it 'returns true for simple flattable key-value pair' do
|
11
|
+
ArrayHashStructure.is_key_value_pair_flattable?(*key_value_pair_1).should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns false for non-flattable nil value' do
|
15
|
+
array = [:key, nil]
|
16
|
+
ArrayHashStructure.is_key_value_pair_flattable?(*array).should be_false
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns false for non-flattable empty array as value' do
|
20
|
+
array = [:key, []]
|
21
|
+
ArrayHashStructure.is_key_value_pair_flattable?(*array).should be_false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns false for non-flattable empty hash as value' do
|
25
|
+
array = [:key, {}]
|
26
|
+
ArrayHashStructure.is_key_value_pair_flattable?(*array).should be_false
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns false for non-flattable key-value pair' do
|
30
|
+
ArrayHashStructure.is_key_value_pair_flattable?(*key_value_pair_1_result).should be_false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.flatten_root!' do
|
35
|
+
it 'flattens flattable key-value pair' do
|
36
|
+
ArrayHashStructure.flatten_key_value_pair!(*key_value_pair_1).should == key_value_pair_1_result
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'does not affect non-flattable key-value pair' do
|
40
|
+
ArrayHashStructure.flatten_key_value_pair!(*key_value_pair_1_result).should == key_value_pair_1_result
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'does not affect non-flattable key-value pair with nil value' do
|
44
|
+
array = [:key, nil]
|
45
|
+
ArrayHashStructure.flatten_key_value_pair!(*array).should == array
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'does not affect non-flattable key-value pair with empty array as value' do
|
49
|
+
array = [:key, []]
|
50
|
+
ArrayHashStructure.flatten_key_value_pair!(*array).should == array
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'does not affect non-flattable key-value pair with empty hash as value' do
|
54
|
+
array = [:key, {}]
|
55
|
+
ArrayHashStructure.flatten_key_value_pair!(*array).should == array
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#flatten_structure!' do
|
60
|
+
it 'returns nil structure as it is' do
|
61
|
+
str = ArrayHashStructure.new(nil_structure).flatten_structure!
|
62
|
+
str.should == nil_structure
|
63
|
+
end
|
64
|
+
it 'returns empty hash as it is' do
|
65
|
+
str = ArrayHashStructure.new(empty_hash_structure).flatten_structure!
|
66
|
+
str.should == empty_hash_structure
|
67
|
+
end
|
68
|
+
it 'returns empty array as it is' do
|
69
|
+
str = ArrayHashStructure.new(empty_array_structure).flatten_structure!
|
70
|
+
str.should == empty_array_structure
|
71
|
+
end
|
72
|
+
it 'flattens simple Hash structure' do
|
73
|
+
str = ArrayHashStructure.new(simple_hash_structure).flatten_structure!
|
74
|
+
str.should == simple_hash_structure_result
|
75
|
+
end
|
76
|
+
it 'flattens complex Hash structure' do
|
77
|
+
str = ArrayHashStructure.new(complex_hash_structure).flatten_structure!
|
78
|
+
str.should == complex_hash_structure_result
|
79
|
+
end
|
80
|
+
it 'flattens complex Hash with mixed string and keys structure' do
|
81
|
+
str = ArrayHashStructure.new(complex_hash_with_mixed_string_and_keys_structure).flatten_structure!
|
82
|
+
str.should == complex_hash_with_mixed_string_and_keys_structure_result
|
83
|
+
end
|
84
|
+
it 'flattens complex Array structure' do
|
85
|
+
str = ArrayHashStructure.new(complex_array_structure).flatten_structure!
|
86
|
+
str.should == complex_array_structure_result
|
87
|
+
end
|
88
|
+
it 'flattens complex nested structure' do
|
89
|
+
str = ArrayHashStructure.new(complex_nested_structure).flatten_structure!
|
90
|
+
#ap VariousStructures.structure4
|
91
|
+
#ap VariousStructures.structure4_result
|
92
|
+
#ap str
|
93
|
+
str.should == complex_nested_structure_result
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'structure_flatter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "structure_flatter"
|
8
|
+
spec.version = StructureFlatter::VERSION
|
9
|
+
spec.authors = ["Munish Goyal"]
|
10
|
+
spec.email = ["munishapc@gmail.com"]
|
11
|
+
spec.description = %q{Flattens hash-array structures by removing redundant information.}
|
12
|
+
spec.summary = %q{Flattens Hash Array Structures}
|
13
|
+
spec.homepage = "http://www.linkedin.com/in/goyalmunish"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake", "~> 0.9"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
24
|
+
spec.add_dependency "awesome_print", "~> 1.2"
|
25
|
+
spec.add_dependency "activesupport", "~> 4.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: structure_flatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Munish Goyal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: awesome_print
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
83
|
+
description: Flattens hash-array structures by removing redundant information.
|
84
|
+
email:
|
85
|
+
- munishapc@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/structure_flatter.rb
|
97
|
+
- lib/structure_flatter/array_hash_structure.rb
|
98
|
+
- lib/structure_flatter/version.rb
|
99
|
+
- spec/inputs/various_key_value_pairs.rb
|
100
|
+
- spec/inputs/various_structures.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
- spec/structure_flatter/array_hash_structure_spec.rb
|
103
|
+
- structure_flatter.gemspec
|
104
|
+
homepage: http://www.linkedin.com/in/goyalmunish
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.2.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Flattens Hash Array Structures
|
128
|
+
test_files:
|
129
|
+
- spec/inputs/various_key_value_pairs.rb
|
130
|
+
- spec/inputs/various_structures.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
- spec/structure_flatter/array_hash_structure_spec.rb
|