map_fields 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/map_fields.rb +10 -8
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
data/lib/map_fields.rb CHANGED
@@ -12,7 +12,7 @@ module MapFields
12
12
  :file_field => 'file',
13
13
  :params => []
14
14
  }
15
- options = default_options.merge(
15
+ options = default_options.merge(
16
16
  self.class.read_inheritable_attribute(:map_fields_options)
17
17
  )
18
18
 
@@ -42,7 +42,7 @@ module MapFields
42
42
  if expected_fields.respond_to?(:call)
43
43
  expected_fields = expected_fields.call(params)
44
44
  end
45
- @mapped_fields = MappedFields.new(session[:map_fields][:file],
45
+ @mapped_fields = MappedFields.new(session[:map_fields][:file],
46
46
  expected_fields,
47
47
  params[:fields],
48
48
  params[:ignore_first_row])
@@ -79,13 +79,13 @@ module MapFields
79
79
  end
80
80
 
81
81
  def map_field_parameters(&block)
82
-
82
+
83
83
  end
84
84
 
85
85
  def map_fields_cleanup
86
86
  if @mapped_fields
87
87
  if session[:map_fields][:file]
88
- File.delete(session[:map_fields][:file])
88
+ File.delete(session[:map_fields][:file])
89
89
  end
90
90
  session[:map_fields] = nil
91
91
  @mapped_fields = nil
@@ -94,11 +94,11 @@ module MapFields
94
94
  end
95
95
 
96
96
  module ClassMethods
97
- def map_fields(action, fields, options = {})
97
+ def map_fields(actions, fields, options = {})
98
98
  write_inheritable_attribute(:map_fields_fields, fields)
99
99
  write_inheritable_attribute(:map_fields_options, options)
100
- before_filter :map_fields, :only => action
101
- after_filter :map_fields_cleanup, :only => action
100
+ before_filter :map_fields, :only => actions
101
+ after_filter :map_fields_cleanup, :only => actions
102
102
  end
103
103
  end
104
104
 
@@ -114,7 +114,7 @@ module MapFields
114
114
  mapping.each do |k,v|
115
115
  unless v.to_i == 0
116
116
  #Numeric mapping
117
- @mapping[v.to_i - 1] = k.to_i - 1
117
+ @mapping[v.to_i - 1] = k.to_i - 1
118
118
  #Text mapping
119
119
  @mapping[fields[v.to_i-1]] = k.to_i - 1
120
120
  #Symbol mapping
@@ -194,4 +194,6 @@ end
194
194
  if defined?(Rails) and defined?(ActionController)
195
195
  ActionController::Base.send(:include, MapFields)
196
196
  ActionController::Base.view_paths.push File.expand_path(File.join(File.dirname(__FILE__), '..', 'views'))
197
+ #This is a hack but the above code is not enough when using bundler and Rails 2.3.5
198
+ ActionController::Base.view_paths.push "app/views"
197
199
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Timberlake
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-12 00:00:00 +02:00
17
+ date: 2010-07-06 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20