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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c57bfcf0be433080cc910278e3bda5a38781dcc8
4
- data.tar.gz: abbb2dc11abff401b46ea8335a4157fa84fe4503
3
+ metadata.gz: a6a6158c48a33d37edc81b20b85fd5e7e8e8050a
4
+ data.tar.gz: 970b0c20a8224ee8050f6417e5496e00a34e9781
5
5
  SHA512:
6
- metadata.gz: fd0df6edbdc025db7c16cb51e75410828319eb466d5ac55039bf36f195c5d335de29838d507e3a31bf6271e816cc3cef16e5021894e909ce843ad0032fe6b761
7
- data.tar.gz: a618260d70b43048033b684739eb92950cbae0512aecd83803426ef46c0f56e05f3599f9f9e771e221b38b4f3ffc1348a52e8df068444b1432fc45a093afa228
6
+ metadata.gz: fc5f64ad0c18242e0e44916141c352d6a7e79632a50098545deffbdb952d8e74109d40b79a0739aef5a369549968d9634046bdbe0c5b83b6b665808a7db33338
7
+ data.tar.gz: 7534ab6657a7be506a45c0924479e3deb2ca0bc02b74d7ba9a1e8a90d2fdbc3cfdb12dea799f14ab45bcf5cf85d0d88a45582479536a4b1315b422e955200fe1
@@ -1,3 +1,8 @@
1
+ ### 0.1.2 / 2018-11-14
2
+
3
+ * Bug fixes
4
+ * Fixed bug where join with lookup operation failed to map header row.
5
+
1
6
  ### 0.1.1 / 2018-11-14
2
7
 
3
8
  * Bug fixes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- array_transform (0.1.1)
4
+ array_transform (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -42,17 +42,23 @@ module ArrayTransform::Operations
42
42
  end
43
43
 
44
44
  def index_lookup_data
45
- @lookup_by_key = lookup_data.inject({}) { |map, row|
46
- map.tap {
47
- map[row[lookup_column_index]] = row.dup.tap { |row_copy| row_copy.delete_at(lookup_column_index) }
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
- row_key = data[row_index][column_index]
55
- data[row_index] = data[row_index] + (lookup_by_key[row_key] || lookup_default)
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
 
@@ -1,3 +1,3 @@
1
1
  module ArrayTransform
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: array_transform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Chadwick