lhs 6.8.0 → 6.8.1
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.
- checksums.yaml +4 -4
- data/lhs.gemspec +1 -0
- data/lib/lhs/complex.rb +111 -135
- data/lib/lhs/concerns/record/chainable.rb +2 -2
- data/lib/lhs/concerns/record/request.rb +2 -2
- data/lib/lhs/version.rb +1 -1
- data/spec/complex/{merge_spec.rb → reduce_spec.rb} +60 -46
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a903adf673e0a9c79c2e060986a78bbfd50ff519
|
4
|
+
data.tar.gz: 2be897ab11167c15ab24413e0a3121d3152ddf51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6155cbf30df50413a5339643d4bfda0126ea7e7c87ae20a21fa7dfc7cd9793448b971c139625d0ec508baa15bee59f318acf8d1c467b64d32479482fa333eddd
|
7
|
+
data.tar.gz: bc9c6bebdab8cbf5c915474e3837b7b6c649b25fc46e5eec1706a515a457e1b4ff28147b814ac1073a59d47f5e475f451d4543588d99f5c0fd87e05dcff683cf
|
data/lhs.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency 'rails', '>= 4.0.0'
|
29
29
|
s.add_development_dependency 'webmock'
|
30
30
|
s.add_development_dependency 'pry'
|
31
|
+
s.add_development_dependency 'pry-byebug'
|
31
32
|
s.add_development_dependency 'capybara'
|
32
33
|
s.add_development_dependency 'rubocop'
|
33
34
|
s.add_development_dependency 'json', '>= 1.8.2'
|
data/lib/lhs/complex.rb
CHANGED
@@ -3,178 +3,154 @@
|
|
3
3
|
# [{ places: [:customer] }, { places: { customer: :contract }}]
|
4
4
|
# and so on
|
5
5
|
class LHS::Complex
|
6
|
+
attr_reader :data
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
data.
|
13
|
-
|
8
|
+
def reduce!(data)
|
9
|
+
if data.is_a?(LHS::Complex)
|
10
|
+
@data = data.data
|
11
|
+
elsif data.is_a?(Array) && !data.empty?
|
12
|
+
@data = data.inject(LHS::Complex.new.reduce!([])) { |acc, datum| acc.merge!(LHS::Complex.new.reduce!(datum)) }.data
|
13
|
+
elsif data.is_a?(Hash) && !data.empty?
|
14
|
+
@data = data.map { |k, v| [k, LHS::Complex.new.reduce!(v)] }.to_h
|
15
|
+
else
|
16
|
+
@data = data
|
14
17
|
end
|
15
|
-
reduce!(result)
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
array.flatten!
|
20
|
-
array.uniq!
|
21
|
-
return array.first if array.length == 1
|
22
|
-
reduce_symbols!(array)
|
23
|
-
return nil if array.blank?
|
24
|
-
array
|
19
|
+
self
|
25
20
|
end
|
26
|
-
private_class_method :reduce!
|
27
21
|
|
28
|
-
def self.
|
29
|
-
|
30
|
-
if element.is_a?(Symbol)
|
31
|
-
array.each do |other_element|
|
32
|
-
array.delete(element) if other_element.is_a?(Hash) && other_element.key?(element)
|
33
|
-
array.delete(element) if other_element.is_a?(Array) && other_element.include?(element)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
22
|
+
def self.reduce(data)
|
23
|
+
new.reduce!(data).unwrap
|
37
24
|
end
|
38
|
-
private_class_method :reduce_symbols!
|
39
25
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
private_class_method :merge_first_level!
|
48
|
-
|
49
|
-
# Merge nested complex (addition) into
|
50
|
-
# an hash or an array (element) of the parent
|
51
|
-
def self.merge_multi_level!(parent, element, addition, key = nil)
|
52
|
-
return if element == addition
|
53
|
-
if addition.is_a?(Symbol) && element.is_a?(Hash)
|
54
|
-
merge_symbol_into_hash!(parent, element, addition, key)
|
55
|
-
elsif addition.is_a?(Symbol) && element.is_a?(Array)
|
56
|
-
merge_symbol_into_array!(parent, element, addition, key)
|
57
|
-
elsif addition.is_a?(Symbol) && element.is_a?(Symbol)
|
58
|
-
add_symbol_to_parent!(parent, element, addition, key)
|
59
|
-
elsif addition.is_a?(Hash) && element.is_a?(Symbol)
|
60
|
-
merge_hash_into_symbol!(parent, element, addition, key)
|
61
|
-
elsif addition.is_a?(Hash) && element.is_a?(Hash)
|
62
|
-
merge_hash_into_hash!(parent, element, addition, key)
|
63
|
-
elsif addition.is_a?(Hash) && element.is_a?(Array)
|
64
|
-
merge_hash_into_array!(element, addition)
|
65
|
-
elsif addition.is_a?(Array) && element.is_a?(Symbol)
|
66
|
-
merge_array_into_symbol!(parent, element, addition, key)
|
67
|
-
elsif addition.is_a?(Array) && element.is_a?(Hash)
|
68
|
-
merge_array_into_hash!(parent, element, addition, key)
|
69
|
-
elsif addition.is_a?(Array) && element.is_a?(Array)
|
70
|
-
merge_array_into_array!(parent, element, addition, key)
|
26
|
+
def merge!(other)
|
27
|
+
if data.is_a?(Symbol)
|
28
|
+
merge_into_symbol!(other)
|
29
|
+
elsif data.is_a?(Array)
|
30
|
+
merge_into_array!(other)
|
31
|
+
elsif data.is_a?(Hash)
|
32
|
+
merge_into_hash!(other)
|
71
33
|
else
|
72
|
-
raise "
|
34
|
+
raise ArgumentError, "Cannot merge #{unwrap} with #{other.unwrap}"
|
73
35
|
end
|
36
|
+
|
37
|
+
self
|
74
38
|
end
|
75
|
-
private_class_method :merge_multi_level!
|
76
39
|
|
77
|
-
def
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
40
|
+
def unwrap
|
41
|
+
if data.is_a?(Array)
|
42
|
+
result = data.map(&:unwrap)
|
43
|
+
result.empty? ? nil : result
|
44
|
+
elsif data.is_a?(Hash)
|
45
|
+
result = data.map { |k, v| [k, v.unwrap] }.to_h
|
46
|
+
result.empty? ? nil : result
|
84
47
|
else
|
85
|
-
|
48
|
+
data
|
86
49
|
end
|
87
50
|
end
|
88
|
-
private_class_method :merge_symbol_into_hash!
|
89
51
|
|
90
|
-
def
|
91
|
-
|
92
|
-
element.push(addition)
|
93
|
-
reduce!(element)
|
52
|
+
def ==(other)
|
53
|
+
unwrap == other.unwrap
|
94
54
|
end
|
95
|
-
private_class_method :merge_symbol_into_array!
|
96
55
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
raise "Can't merge that complex: #{addition} -> #{parent} (#{element})"
|
56
|
+
private
|
57
|
+
|
58
|
+
def merge_into_array!(other)
|
59
|
+
if data.empty?
|
60
|
+
@data = other.data
|
61
|
+
elsif other.data.is_a?(Symbol)
|
62
|
+
merge_symbol_into_array!(other)
|
63
|
+
elsif other.data.is_a?(Array)
|
64
|
+
merge_array_into_array!(other)
|
65
|
+
elsif other.data.is_a?(Hash)
|
66
|
+
merge_hash_into_array!(other)
|
109
67
|
end
|
110
68
|
end
|
111
|
-
private_class_method :merge_hash_into_symbol!
|
112
69
|
|
113
|
-
def
|
114
|
-
|
115
|
-
|
116
|
-
parent[key] = addition
|
70
|
+
def merge_symbol_into_array!(other)
|
71
|
+
return if data.include?(other)
|
72
|
+
data.push(other)
|
117
73
|
end
|
118
|
-
private_class_method :merge_array_into_symbol!
|
119
74
|
|
120
|
-
def
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
element
|
75
|
+
def merge_array_into_array!(other)
|
76
|
+
@data = other.data.inject(self) { |acc, datum| acc.merge!(datum) }.data
|
77
|
+
end
|
78
|
+
|
79
|
+
def merge_hash_into_array!(other)
|
80
|
+
@data = [].tap do |new_data|
|
81
|
+
data.each do |element|
|
82
|
+
if element.data.is_a?(Symbol)
|
83
|
+
# remove keys that were in the hash
|
84
|
+
new_data << element if !other.data.key?(element.data)
|
85
|
+
elsif element.data.is_a?(Array)
|
86
|
+
new_data << element
|
87
|
+
elsif element.data.is_a?(Hash)
|
88
|
+
new_data << element.merge!(other)
|
89
|
+
end
|
128
90
|
end
|
129
91
|
end
|
92
|
+
|
93
|
+
# add it to the array if there was no hash to merge it
|
94
|
+
data.push(other) if !data.any? { |element| element.data.is_a?(Hash) }
|
130
95
|
end
|
131
|
-
private_class_method :merge_hash_into_hash!
|
132
96
|
|
133
|
-
def
|
134
|
-
|
135
|
-
|
97
|
+
def merge_into_hash!(other)
|
98
|
+
if data.empty?
|
99
|
+
@data = other.data
|
100
|
+
elsif other.data.is_a?(Symbol)
|
101
|
+
merge_symbol_into_hash!(other)
|
102
|
+
elsif other.data.is_a?(Array)
|
103
|
+
merge_array_into_hash!(other)
|
104
|
+
elsif other.data.is_a?(Hash)
|
105
|
+
merge_hash_into_hash!(other)
|
136
106
|
end
|
137
107
|
end
|
138
|
-
private_class_method :merge_array_into_hash!
|
139
108
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
|
109
|
+
def merge_symbol_into_hash!(other)
|
110
|
+
return if data.key?(other.data)
|
111
|
+
|
112
|
+
@data = [LHS::Complex.new.reduce!(data), other]
|
113
|
+
end
|
114
|
+
|
115
|
+
def merge_array_into_hash!(other)
|
116
|
+
@data = other.data.inject(self) { |acc, datum| acc.merge!(datum) }.data
|
144
117
|
end
|
145
|
-
private_class_method :merge_array_into_array!
|
146
118
|
|
147
|
-
def
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
119
|
+
def merge_hash_into_hash!(other)
|
120
|
+
other.data.each do |k, v|
|
121
|
+
if data.key?(k)
|
122
|
+
data[k] = data[k].merge!(v)
|
123
|
+
else
|
124
|
+
data[k] = v
|
153
125
|
end
|
154
126
|
end
|
155
|
-
array.push(addition)
|
156
|
-
reduce!(array)
|
157
127
|
end
|
158
|
-
private_class_method :merge_hash_into_array!
|
159
128
|
|
160
|
-
def
|
161
|
-
if
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
add_symbol_to_hash_parent!(parent, element, addition, key)
|
168
|
-
else
|
169
|
-
raise "Can't merge that complex: #{addition} -> #{parent} (#{element})"
|
129
|
+
def merge_into_symbol!(other)
|
130
|
+
if other.data.is_a?(Symbol)
|
131
|
+
merge_symbol_into_symbol!(other)
|
132
|
+
elsif other.data.is_a?(Array)
|
133
|
+
merge_array_into_symbol!(other)
|
134
|
+
elsif other.data.is_a?(Hash)
|
135
|
+
merge_hash_into_symbol!(other)
|
170
136
|
end
|
171
137
|
end
|
172
|
-
private_class_method :add_symbol_to_parent!
|
173
138
|
|
174
|
-
def
|
175
|
-
return if
|
176
|
-
|
177
|
-
|
139
|
+
def merge_symbol_into_symbol!(other)
|
140
|
+
return if other.data == data
|
141
|
+
|
142
|
+
@data = [LHS::Complex.new.reduce!(data), other]
|
143
|
+
end
|
144
|
+
|
145
|
+
def merge_array_into_symbol!(other)
|
146
|
+
@data = other.data.unshift(LHS::Complex.new.reduce!(data)).uniq { |a| a.unwrap }
|
147
|
+
end
|
148
|
+
|
149
|
+
def merge_hash_into_symbol!(other)
|
150
|
+
if other.data.key?(data)
|
151
|
+
@data = other.data
|
152
|
+
else
|
153
|
+
@data = [LHS::Complex.new.reduce!(data), other]
|
154
|
+
end
|
178
155
|
end
|
179
|
-
private_class_method :add_symbol_to_hash_parent!
|
180
156
|
end
|
@@ -288,7 +288,7 @@ class LHS::Record
|
|
288
288
|
end
|
289
289
|
|
290
290
|
def chain_includes
|
291
|
-
LHS::Complex.
|
291
|
+
LHS::Complex.reduce(
|
292
292
|
_links
|
293
293
|
.select { |link| link.is_a?(Include) && link.data.present? }
|
294
294
|
.map { |link| link.data }
|
@@ -296,7 +296,7 @@ class LHS::Record
|
|
296
296
|
end
|
297
297
|
|
298
298
|
def chain_references
|
299
|
-
LHS::Complex.
|
299
|
+
LHS::Complex.reduce(
|
300
300
|
_links
|
301
301
|
.select { |link| link.is_a?(Reference) && link.data.present? }
|
302
302
|
.map { |link| link.data }
|
@@ -193,8 +193,8 @@ class LHS::Record
|
|
193
193
|
data = LHC.request(options.compact).map do |response|
|
194
194
|
LHS::Data.new(response.body, nil, self, response.request)
|
195
195
|
end
|
196
|
-
including = LHS::Complex.
|
197
|
-
referencing = LHS::Complex.
|
196
|
+
including = LHS::Complex.reduce options.compact.map { |options| options.delete(:including) }.compact
|
197
|
+
referencing = LHS::Complex.reduce options.compact.map { |options| options.delete(:referencing) }.compact
|
198
198
|
data = restore_with_nils(data, locate_nils(options)) # nil objects in data provide location information for mapping
|
199
199
|
data = LHS::Data.new(data, nil, self)
|
200
200
|
handle_includes(including, data, referencing) if including.present? && !data.empty?
|
data/lib/lhs/version.rb
CHANGED
@@ -1,125 +1,139 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Complex do
|
4
|
+
it 'returns nil when result is empty' do
|
5
|
+
expect(LHS::Complex.reduce([])).to be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'forwards primitive types' do
|
9
|
+
expect(LHS::Complex.reduce(entry_id: 123)).to eq(entry_id: 123)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'fails when trying to merge primitive types' do
|
13
|
+
expect {
|
14
|
+
LHS::Complex.reduce([{ entry: true }, { entry: :content }])
|
15
|
+
}.to raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
|
4
18
|
context 'first level' do
|
5
|
-
context '
|
6
|
-
it '
|
7
|
-
expect(LHS::Complex.
|
19
|
+
context 'reduces symbols into/with X' do
|
20
|
+
it 'reduces symbols into hash' do
|
21
|
+
expect(LHS::Complex.reduce([
|
8
22
|
{ entries: :contract },
|
9
23
|
:entries
|
10
24
|
])).to eq(entries: :contract)
|
11
25
|
end
|
12
26
|
|
13
|
-
it '
|
14
|
-
expect(LHS::Complex.
|
27
|
+
it 'reduces symbols into array' do
|
28
|
+
expect(LHS::Complex.reduce([
|
15
29
|
[:contracts],
|
16
30
|
:entries
|
17
31
|
])).to eq([:contracts, :entries])
|
18
|
-
expect(LHS::Complex.
|
32
|
+
expect(LHS::Complex.reduce([
|
19
33
|
[:entries],
|
20
34
|
:entries
|
21
35
|
])).to eq(:entries)
|
22
36
|
end
|
23
37
|
|
24
|
-
it '
|
25
|
-
expect(LHS::Complex.
|
38
|
+
it 'reduces symbols with symbols' do
|
39
|
+
expect(LHS::Complex.reduce([
|
26
40
|
:contracts,
|
27
41
|
:entries
|
28
42
|
])).to eq([:contracts, :entries])
|
29
|
-
expect(LHS::Complex.
|
43
|
+
expect(LHS::Complex.reduce([
|
30
44
|
:entries,
|
31
45
|
:entries
|
32
46
|
])).to eq(:entries)
|
33
47
|
end
|
34
48
|
end
|
35
49
|
|
36
|
-
context '
|
37
|
-
it '
|
38
|
-
expect(LHS::Complex.
|
50
|
+
context 'reduces arrays into/with X' do
|
51
|
+
it 'reduces arrays into an hash' do
|
52
|
+
expect(LHS::Complex.reduce([
|
39
53
|
{ entries: :contract },
|
40
54
|
[:entries]
|
41
55
|
])).to eq(entries: :contract)
|
42
|
-
expect(LHS::Complex.
|
56
|
+
expect(LHS::Complex.reduce([
|
43
57
|
{ entries: :contract },
|
44
58
|
[:products]
|
45
59
|
])).to eq([{ entries: :contract }, :products])
|
46
60
|
end
|
47
61
|
|
48
|
-
it '
|
49
|
-
expect(LHS::Complex.
|
62
|
+
it 'reduces arrays into an arrays' do
|
63
|
+
expect(LHS::Complex.reduce([
|
50
64
|
[:entries],
|
51
65
|
[:entries]
|
52
66
|
])).to eq(:entries)
|
53
|
-
expect(LHS::Complex.
|
67
|
+
expect(LHS::Complex.reduce([
|
54
68
|
[:entries],
|
55
69
|
[:products]
|
56
70
|
])).to eq([:entries, :products])
|
57
71
|
end
|
58
72
|
|
59
|
-
it '
|
60
|
-
expect(LHS::Complex.
|
73
|
+
it 'reduces arrays into an symbols' do
|
74
|
+
expect(LHS::Complex.reduce([
|
61
75
|
:entries,
|
62
76
|
[:entries]
|
63
77
|
])).to eq(:entries)
|
64
|
-
expect(LHS::Complex.
|
78
|
+
expect(LHS::Complex.reduce([
|
65
79
|
:entries,
|
66
80
|
[:products]
|
67
81
|
])).to eq([:entries, :products])
|
68
82
|
end
|
69
83
|
end
|
70
84
|
|
71
|
-
context '
|
72
|
-
it '
|
73
|
-
expect(LHS::Complex.
|
85
|
+
context 'reduces hashes into/with X' do
|
86
|
+
it 'reduces hash into an hash' do
|
87
|
+
expect(LHS::Complex.reduce([
|
74
88
|
{ entries: :contract },
|
75
89
|
{ entries: :products }
|
76
90
|
])).to eq(entries: [:contract, :products])
|
77
|
-
expect(LHS::Complex.
|
91
|
+
expect(LHS::Complex.reduce([
|
78
92
|
{ entries: :contract },
|
79
93
|
{ entries: :contract }
|
80
94
|
])).to eq(entries: :contract)
|
81
95
|
end
|
82
96
|
|
83
|
-
it '
|
84
|
-
expect(LHS::Complex.
|
97
|
+
it 'reduces hash into an array' do
|
98
|
+
expect(LHS::Complex.reduce([
|
85
99
|
[:entries],
|
86
100
|
{ entries: :products }
|
87
101
|
])).to eq(entries: :products)
|
88
|
-
expect(LHS::Complex.
|
102
|
+
expect(LHS::Complex.reduce([
|
89
103
|
[{ entries: :contract }],
|
90
104
|
{ entries: :contract }
|
91
105
|
])).to eq(entries: :contract)
|
92
106
|
end
|
93
107
|
|
94
|
-
it '
|
95
|
-
expect(LHS::Complex.
|
108
|
+
it 'reduces hash into a symbol' do
|
109
|
+
expect(LHS::Complex.reduce([
|
96
110
|
:entries,
|
97
111
|
{ entries: :products }
|
98
112
|
])).to eq(entries: :products)
|
99
|
-
expect(LHS::Complex.
|
113
|
+
expect(LHS::Complex.reduce([
|
100
114
|
:products,
|
101
115
|
{ entries: :contract }
|
102
116
|
])).to eq([:products, { entries: :contract }])
|
103
117
|
end
|
104
118
|
end
|
105
119
|
|
106
|
-
context '
|
107
|
-
it '
|
108
|
-
expect(LHS::Complex.
|
120
|
+
context 'reduces array into/with X' do
|
121
|
+
it 'reduces array into hash' do
|
122
|
+
expect(LHS::Complex.reduce([
|
109
123
|
{ entries: :contract },
|
110
124
|
[:entries, :products]
|
111
125
|
])).to eq([{ entries: :contract }, :products])
|
112
126
|
end
|
113
127
|
|
114
|
-
it '
|
115
|
-
expect(LHS::Complex.
|
128
|
+
it 'reduces array into array' do
|
129
|
+
expect(LHS::Complex.reduce([
|
116
130
|
[:contracts],
|
117
131
|
[:entries, :products, :contracts]
|
118
132
|
])).to eq([:contracts, :entries, :products])
|
119
133
|
end
|
120
134
|
|
121
|
-
it '
|
122
|
-
expect(LHS::Complex.
|
135
|
+
it 'reduces array with symbols' do
|
136
|
+
expect(LHS::Complex.reduce([
|
123
137
|
:contracts,
|
124
138
|
[:entries, :products]
|
125
139
|
])).to eq([:contracts, :entries, :products])
|
@@ -128,8 +142,8 @@ describe LHS::Complex do
|
|
128
142
|
end
|
129
143
|
|
130
144
|
context 'multi-level' do
|
131
|
-
it '
|
132
|
-
expect(LHS::Complex.
|
145
|
+
it 'reduces a complex multi-level example' do
|
146
|
+
expect(LHS::Complex.reduce([
|
133
147
|
:contracts,
|
134
148
|
[:entries, products: { content_ads: :address }],
|
135
149
|
products: { content_ads: { place: :location } }
|
@@ -140,19 +154,19 @@ describe LHS::Complex do
|
|
140
154
|
])
|
141
155
|
end
|
142
156
|
|
143
|
-
it '
|
144
|
-
expect(LHS::Complex.
|
157
|
+
it 'reduces another complex multi-level example' do
|
158
|
+
expect(LHS::Complex.reduce([
|
145
159
|
[entries: :content_ads, products: :price],
|
146
160
|
[:entries, products: { content_ads: :address }],
|
147
161
|
[entries: { content_ads: :owner }, products: [{ price: :region }, :image, { content_ads: :owner }]]
|
148
162
|
])).to eq(
|
149
163
|
entries: { content_ads: :owner },
|
150
|
-
products: [{ content_ads: [:address, :owner]
|
164
|
+
products: [{ content_ads: [:address, :owner], price: :region }, :image]
|
151
165
|
)
|
152
166
|
end
|
153
167
|
|
154
|
-
it '
|
155
|
-
expect(LHS::Complex.
|
168
|
+
it 'reduces another complex multi-level example' do
|
169
|
+
expect(LHS::Complex.reduce([
|
156
170
|
{ entries: :products },
|
157
171
|
{ entries: [:customer, :contracts] }
|
158
172
|
])).to eq(
|
@@ -160,8 +174,8 @@ describe LHS::Complex do
|
|
160
174
|
)
|
161
175
|
end
|
162
176
|
|
163
|
-
it '
|
164
|
-
expect(LHS::Complex.
|
177
|
+
it 'reduces another complex multi-level example' do
|
178
|
+
expect(LHS::Complex.reduce([
|
165
179
|
{ entries: { customer: :contracts } },
|
166
180
|
{ entries: [:customer, :content_ads] }
|
167
181
|
])).to eq(
|
@@ -170,7 +184,7 @@ describe LHS::Complex do
|
|
170
184
|
end
|
171
185
|
|
172
186
|
it 'reduces properly' do
|
173
|
-
expect(LHS::Complex.
|
187
|
+
expect(LHS::Complex.reduce([
|
174
188
|
[:entries, :place, :content_ads], [{ place: :content_ads }], { content_ads: :place }
|
175
189
|
])).to eq(
|
176
190
|
[:entries, { place: :content_ads, content_ads: :place }]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.8.
|
4
|
+
version: 6.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-byebug
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: capybara
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +235,7 @@ files:
|
|
221
235
|
- spec/collection/meta_data_spec.rb
|
222
236
|
- spec/collection/respond_to_spec.rb
|
223
237
|
- spec/collection/without_object_items_spec.rb
|
224
|
-
- spec/complex/
|
238
|
+
- spec/complex/reduce_spec.rb
|
225
239
|
- spec/data/collection_spec.rb
|
226
240
|
- spec/data/equality_spec.rb
|
227
241
|
- spec/data/inspect_spec.rb
|
@@ -372,7 +386,7 @@ test_files:
|
|
372
386
|
- spec/collection/meta_data_spec.rb
|
373
387
|
- spec/collection/respond_to_spec.rb
|
374
388
|
- spec/collection/without_object_items_spec.rb
|
375
|
-
- spec/complex/
|
389
|
+
- spec/complex/reduce_spec.rb
|
376
390
|
- spec/data/collection_spec.rb
|
377
391
|
- spec/data/equality_spec.rb
|
378
392
|
- spec/data/inspect_spec.rb
|