active_admin_import 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,12 @@ module ActiveAdminImport
7
7
  def store data, headers
8
8
  result = @resource.transaction do
9
9
  options[:before_batch_import].call(data, headers) if options[:before_batch_import].is_a?(Proc)
10
- result = resource.import headers, data, :validate => options[:validate]
10
+ result = resource.import headers, data, {
11
+ :validate => options[:validate],
12
+ :on_duplicate_key_update => options[:on_duplicate_key_update],
13
+ :ignore => options[:ignore],
14
+ :timestamps => options[:timestamps]
15
+ }
11
16
  options[:after_batch_import].call(data, headers) if options[:after_batch_import].is_a?(Proc)
12
17
  result
13
18
  end
@@ -18,7 +23,6 @@ module ActiveAdminImport
18
23
  Hash[headers.zip(headers.map { |el| el.underscore.gsub(/\s+/, '_') })]
19
24
  end
20
25
 
21
-
22
26
  def initialize resource, file, options
23
27
  @resource = resource
24
28
  @file = file
@@ -39,12 +43,9 @@ module ActiveAdminImport
39
43
  @result.merge!(self.store(lines, @headers.values)){|key,val1,val2| val1+val2}
40
44
  end
41
45
 
42
-
43
46
  def import
44
-
45
47
  options[:before_import].call(@resource, @file, @options) if options[:before_import].is_a?(Proc)
46
48
  lines = []
47
-
48
49
  batch_size = @options[:batch_size].to_i
49
50
  IO.foreach(file.path) do |line|
50
51
  if @headers.empty?
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminImport
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chronic
16
- requirement: &70329918285720 !ruby/object:Gem::Requirement
16
+ requirement: &70313477456520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70329918285720
24
+ version_requirements: *70313477456520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord-import
27
- requirement: &70329918300940 !ruby/object:Gem::Requirement
27
+ requirement: &70313477471600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70329918300940
35
+ version_requirements: *70313477471600
36
36
  description: CSV import for Active Admin
37
37
  email:
38
38
  - fedoronchuk@gmail.com