activerecord_csv_importer 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2dda1af501f14aedbe3f83187fd5f809da764e
|
4
|
+
data.tar.gz: 7efbf3e7a9db826d2d7219ef8b57e68e31807b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11fde7090c4d650e99c0423ca5b8896d53184fb38fc9b4601747fb9879cb26449f7c85a0db18b82bb840f72cde469013f3c6ab8560c439bcb7cc95134242d790
|
7
|
+
data.tar.gz: fe7af3a43bcddb619102b0069cf385bc3386dffa8e4e7de00c5612afce6275092f0636ad8610493ce858fd053ca43b506ca10090ebaffa9405e96c5e8a8429cb
|
@@ -15,6 +15,10 @@ module ActiveRecordCSVImporter
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def columns_with_definition_names
|
19
|
+
columns.select(&:definition).map(&:name)
|
20
|
+
end
|
21
|
+
|
18
22
|
def column_name_for_model_attribute(attribute)
|
19
23
|
column = columns.find { |c|
|
20
24
|
c.definition.attribute == attribute if c.definition
|
@@ -42,10 +46,6 @@ module ActiveRecordCSVImporter
|
|
42
46
|
(column_definitions - columns.map(&:definition)).map(&:name).map(&:to_s)
|
43
47
|
end
|
44
48
|
|
45
|
-
def column_definition_names
|
46
|
-
column_definitions.map(&:name).map(&:to_s)
|
47
|
-
end
|
48
|
-
|
49
49
|
private
|
50
50
|
|
51
51
|
def find_column_definition(name)
|
@@ -53,5 +53,9 @@ module ActiveRecordCSVImporter
|
|
53
53
|
column_definition.match?(name)
|
54
54
|
}
|
55
55
|
end
|
56
|
+
|
57
|
+
def column_definition_names
|
58
|
+
column_definitions.map(&:name).map(&:to_s)
|
59
|
+
end
|
56
60
|
end
|
57
61
|
end
|
@@ -38,7 +38,7 @@ module ActiveRecordCSVImporter
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def import_rows(set)
|
41
|
-
config.model.import(header.
|
41
|
+
config.model.import(header.columns_with_definition_names.dup, set, config.on_duplicate_key)
|
42
42
|
end
|
43
43
|
|
44
44
|
def add_to_report(response, set)
|
@@ -50,7 +50,7 @@ module ActiveRecordCSVImporter
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def columns_for(model)
|
53
|
-
model.attributes.values_at(*header.
|
53
|
+
model.attributes.values_at(*header.columns_with_definition_names)
|
54
54
|
end
|
55
55
|
|
56
56
|
# Error from the model mapped back to the CSV header if we can
|