xls_porter 0.1.1 → 1.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.
- data/lib/xls_porter.rb +7 -10
- metadata +2 -2
data/lib/xls_porter.rb
CHANGED
@@ -59,19 +59,18 @@ module XlsPorter
|
|
59
59
|
value = row[i]
|
60
60
|
value = value.strip if value.is_a?(String)
|
61
61
|
column = columns[i]
|
62
|
+
attribute = record.read_attribute(column)
|
62
63
|
if column == "id" and update == "new"
|
63
|
-
record
|
64
|
+
eval("record.#{column}=value")
|
64
65
|
elsif ignore_columns.include?(column)
|
65
66
|
#skip if column is ignored
|
66
|
-
elsif
|
67
|
+
elsif attribute.blank? and value.blank?
|
67
68
|
#skip if both are either nil or empty
|
68
69
|
elsif [DateTime, Time, Date].include?(value.class)
|
69
|
-
if
|
70
|
-
record[column] = value
|
71
|
-
end
|
70
|
+
eval("record.#{column}=value") if attribute.to_f != value.to_f
|
72
71
|
else
|
73
|
-
if
|
74
|
-
record
|
72
|
+
if attribute != value
|
73
|
+
eval("record.#{column}=value")
|
75
74
|
update = "updated" if update == "exist"
|
76
75
|
update_notes = [] if update_notes.nil?
|
77
76
|
update_notes << column
|
@@ -86,9 +85,7 @@ module XlsPorter
|
|
86
85
|
update = "exception"
|
87
86
|
update_notes = exception.to_s
|
88
87
|
end
|
89
|
-
record
|
90
|
-
record["update_notes"] = update_notes
|
91
|
-
updates << record # if %w(new updated).include?(update) #not record.changed.empty?
|
88
|
+
updates << record.attributes.merge({ update: update, update_notes: update_notes }) # if %w(new updated).include?(update) #not record.changed.empty?
|
92
89
|
end
|
93
90
|
end
|
94
91
|
return {:columns => (%w(update update_notes) + columns), :updates => updates, :model => model.name}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xls_porter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: '1.1'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|