spreadsheet_model 0.3.2 → 0.3.3
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/Gemfile.lock +1 -1
- data/lib/spreadsheet_model/version.rb +1 -1
- data/lib/spreadsheet_model.rb +10 -3
- 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: 9f62c026036ee840186938e7f4deaf09f56a6ba2
|
4
|
+
data.tar.gz: 33ad2c4688541958f524c29468df843392e88a68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39a82a8273359b3574f7f27875a85dfad342c9b4d2b09e752431f0e849315c65a8e1d72ef9393a40d36ecfef80c13286628ffba054ec945efaefeab55e51fa0f
|
7
|
+
data.tar.gz: bb997b749907bdbbabc25acb2e2f74c460fe2ba2bad07a0bad68f50824b361a1db8edee7c5bd9ce8da7f9109a51d2098d6f38b0553635e97e113f2f6036c1c87
|
data/Gemfile.lock
CHANGED
data/lib/spreadsheet_model.rb
CHANGED
@@ -40,11 +40,17 @@ module SpreadsheetModel
|
|
40
40
|
sheets.each do |sheet|
|
41
41
|
rows = sheet.rows.dup
|
42
42
|
header = rows.shift
|
43
|
-
|
43
|
+
|
44
|
+
store_hash = rows.each_with_object({}) do |row, store_hash|
|
44
45
|
row_hash = Hash[*header.zip(row).flatten]
|
45
46
|
row_hash = @import_callback.call(row_hash) if @import_callback
|
46
|
-
write_rows = [
|
47
|
-
|
47
|
+
write_rows = [store_hash[row[0]], row_hash].compact.flatten
|
48
|
+
store_hash[row[0]] = write_rows
|
49
|
+
store_hash
|
50
|
+
end
|
51
|
+
|
52
|
+
store_hash.each do |k, v|
|
53
|
+
write_cache(k, v)
|
48
54
|
end
|
49
55
|
end
|
50
56
|
write_cache('__cached', true)
|
@@ -134,6 +140,7 @@ module SpreadsheetModel
|
|
134
140
|
end
|
135
141
|
|
136
142
|
def self.row_to_instance(row)
|
143
|
+
return nil unless row
|
137
144
|
attributes = row.select { |key, _| @@column_names.include?(key.to_sym) }
|
138
145
|
|
139
146
|
if attributes['type'].to_s.present?
|