map_fields 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/map_fields.rb +18 -16
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/map_fields.rb
CHANGED
@@ -49,23 +49,25 @@ module MapFields
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
@
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
unless @map_fields_error
|
53
|
+
@rows = []
|
54
|
+
begin
|
55
|
+
FasterCSV.foreach(session[:map_fields][:file]) do |row|
|
56
|
+
@rows << row
|
57
|
+
break if @rows.size == 10
|
58
|
+
end
|
59
|
+
rescue FasterCSV::MalformedCSVError => e
|
60
|
+
@map_fields_error = e
|
61
|
+
end
|
62
|
+
expected_fields = self.class.read_inheritable_attribute(:map_fields_fields)
|
63
|
+
if expected_fields.respond_to?(:call)
|
64
|
+
expected_fields = expected_fields.call(params)
|
65
|
+
end
|
66
|
+
@fields = ([nil] + expected_fields).inject([]){ |o, e| o << [e, o.size]}
|
67
|
+
@parameters = []
|
68
|
+
options[:params].each do |param|
|
69
|
+
@parameters += ParamsParser.parse(params, param)
|
57
70
|
end
|
58
|
-
rescue FasterCSV::MalformedCSVError => e
|
59
|
-
@map_fields_error = e
|
60
|
-
end
|
61
|
-
expected_fields = self.class.read_inheritable_attribute(:map_fields_fields)
|
62
|
-
if expected_fields.respond_to?(:call)
|
63
|
-
expected_fields = expected_fields.call(params)
|
64
|
-
end
|
65
|
-
@fields = ([nil] + expected_fields).inject([]){ |o, e| o << [e, o.size]}
|
66
|
-
@parameters = []
|
67
|
-
options[:params].each do |param|
|
68
|
-
@parameters += ParamsParser.parse(params, param)
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|