array_transform 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/array_transform/operations/join_with_lookup.rb +12 -6
- data/lib/array_transform/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6a6158c48a33d37edc81b20b85fd5e7e8e8050a
|
4
|
+
data.tar.gz: 970b0c20a8224ee8050f6417e5496e00a34e9781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc5f64ad0c18242e0e44916141c352d6a7e79632a50098545deffbdb952d8e74109d40b79a0739aef5a369549968d9634046bdbe0c5b83b6b665808a7db33338
|
7
|
+
data.tar.gz: 7534ab6657a7be506a45c0924479e3deb2ca0bc02b74d7ba9a1e8a90d2fdbc3cfdb12dea799f14ab45bcf5cf85d0d88a45582479536a4b1315b422e955200fe1
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -42,17 +42,23 @@ module ArrayTransform::Operations
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def index_lookup_data
|
45
|
-
@lookup_by_key
|
46
|
-
|
47
|
-
map
|
45
|
+
@lookup_by_key ||= begin
|
46
|
+
lookup_data.inject({}) { |map, row|
|
47
|
+
map.tap {
|
48
|
+
map[row[lookup_column_index]] = row.dup.tap { |row_copy| row_copy.delete_at(lookup_column_index) }
|
49
|
+
}
|
48
50
|
}
|
49
|
-
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
def join_lookup_data
|
53
55
|
data.each_with_index do |row, row_index|
|
54
|
-
|
55
|
-
|
56
|
+
if row_index == 0
|
57
|
+
data[row_index] = data[row_index] + lookup_data[0].dup.tap { |row_copy| row_copy.delete_at(lookup_column_index) }
|
58
|
+
else
|
59
|
+
row_key = data[row_index][column_index]
|
60
|
+
data[row_index] = data[row_index] + (lookup_by_key[row_key] || lookup_default)
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
58
64
|
|