active_admin_import 4.0.0 → 4.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/README.md +34 -28
- data/active_admin_import.gemspec +1 -1
- data/lib/active_admin_import/importer.rb +15 -2
- data/lib/active_admin_import/version.rb +2 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72a624e96a7c740179d82959a81d6eceee7987813a6dbed662a5113eb41e76d2
|
4
|
+
data.tar.gz: 07ddbc628d18fa4b3a006a2709858001146f86d94f487368eca2c6e247f03ece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08f7de1d997ace9ecb6e741e95f66be1a14bb1b044683f41d0c27d24ec4b1bd995f0a5e2feb2f20dca07704416e809a5735aa39dc153c7497bbbce650003db4b'
|
7
|
+
data.tar.gz: 8fc7ac974e5d03f6982fba484cc3ed2c54b9f5c9e3a38dd7a9ec1241100bb95e055639a75ffe79a9b3fffffbe06f3ab7c4a3ac162b8e63cd4316c7a73af2d7c8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,31 +1,28 @@
|
|
1
1
|
# ActiveAdminImport
|
2
|
-
[The most fastest and efficient CSV import for Active Admin
|
3
|
-
with support of validations, bulk inserts and encodings handling](http://activeadmin-plugins.github.io/active_admin_import/)
|
4
2
|
|
3
|
+
[![Travis Build ][build_badge]][build_link]
|
4
|
+
[![Coverage Status][coveralls_badge]][coveralls_link]
|
5
|
+
[![Code Climate ][codeclimate_badge]][codeclimate_link]
|
6
|
+
[![Gem Version ][rubygems_badge]][rubygems_link]
|
7
|
+
[![License ][license_badge]][license_link]
|
5
8
|
|
6
9
|
|
7
|
-
|
8
|
-
[](https://gemnasium.com/activeadmin-plugins/active_admin_import)
|
9
|
-
[](https://coveralls.io/r/activeadmin-plugins/active_admin_import)
|
10
|
-
[](https://codeclimate.com/github/activeadmin-plugins/active_admin_import)
|
11
|
-
[](https://rubygems.org/gems/active_admin_import)
|
12
|
-
[](http://Fivell.mit-license.org)
|
10
|
+
The most fastest and efficient CSV import for Active Admin with support of validations, bulk inserts and encodings handling.
|
13
11
|
|
12
|
+
For more about ActiveAdminImport installation and usage, check [Documentation website](http://activeadmin-plugins.github.io/active_admin_import/) and [Wiki pages](https://github.com/activeadmin-plugins/active_admin_import/wiki) for some specific cases and caveats.
|
14
13
|
|
15
14
|
|
16
|
-
|
15
|
+
## Installation
|
17
16
|
|
18
17
|
Add this line to your application's Gemfile:
|
19
18
|
|
20
19
|
```ruby
|
21
|
-
gem "active_admin_import"
|
22
|
-
|
20
|
+
gem "active_admin_import"
|
23
21
|
```
|
24
22
|
or
|
25
23
|
|
26
24
|
```ruby
|
27
25
|
gem "active_admin_import" , github: "activeadmin-plugins/active_admin_import"
|
28
|
-
|
29
26
|
```
|
30
27
|
|
31
28
|
And then execute:
|
@@ -33,18 +30,15 @@ And then execute:
|
|
33
30
|
$ bundle
|
34
31
|
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
<li> and more...</li>
|
46
|
-
</ol>
|
47
|
-
|
33
|
+
## Features
|
34
|
+
* Replacements/Updates support
|
35
|
+
* Encoding handling
|
36
|
+
* CSV options
|
37
|
+
* Ability to describe/change CSV headers
|
38
|
+
* Bulk import (activerecord-import)
|
39
|
+
* Callbacks
|
40
|
+
* Zip files
|
41
|
+
* and more...
|
48
42
|
|
49
43
|
|
50
44
|
#### Basic usage
|
@@ -61,16 +55,17 @@ Tool | Description
|
|
61
55
|
--------------------- | -----------
|
62
56
|
:back |resource action to redirect after processing
|
63
57
|
:csv_options |hash with column separator, row separator, etc
|
64
|
-
:validate |bool
|
58
|
+
:validate |bool (true by default), perform validations or not
|
59
|
+
:batch_transaction |bool (false by default), if transaction is used when batch importing and works when :validate is set to true
|
65
60
|
:batch_size |integer value of max record count inserted by 1 query/transaction
|
66
|
-
:batch_transaction |bool (false by default), if transaction is used when batch importing and works when :validate is set to true
|
67
61
|
:before_import |proc for before import action, hook called with importer object
|
68
62
|
:after_import |proc for after import action, hook called with importer object
|
69
63
|
:before_batch_import |proc for before each batch action, called with importer object
|
70
64
|
:after_batch_import |proc for after each batch action, called with importer object
|
71
|
-
:on_duplicate_key_update|an Array or Hash, tells activerecord-import to use MySQL's ON DUPLICATE KEY UPDATE or Postgres 9.5+ ON CONFLICT DO UPDATE ability
|
65
|
+
:on_duplicate_key_update|an Array or Hash, tells activerecord-import to use MySQL's ON DUPLICATE KEY UPDATE or Postgres 9.5+/SQLite 3.24.0+ ON CONFLICT DO UPDATE ability
|
66
|
+
:on_duplicate_key_ignore|bool, tells activerecord-import to use MySQL's INSERT IGNORE or Postgres 9.5+ ON CONFLICT DO NOTHING or SQLite's INSERT OR IGNORE ability
|
67
|
+
:ignore |bool, alias for on_duplicate_key_ignore
|
72
68
|
:timestamps |bool, tells activerecord-import to not add timestamps (if false) even if record timestamps is disabled in ActiveRecord::Base
|
73
|
-
:ignore |bool, tells activerecord-import to use MySQL's INSERT IGNORE ability
|
74
69
|
:template |custom template rendering
|
75
70
|
:template_object |object passing to view
|
76
71
|
:resource_class |resource class name
|
@@ -96,6 +91,17 @@ Tool | Description
|
|
96
91
|
[rchardet]: https://github.com/jmhodges/rchardet
|
97
92
|
[activerecord-import]: https://github.com/zdennis/activerecord-import
|
98
93
|
|
94
|
+
[build_badge]: https://travis-ci.org/activeadmin-plugins/active_admin_import.svg?branch=master
|
95
|
+
[build_link]: https://travis-ci.org/activeadmin-plugins/active_admin_import
|
96
|
+
[coveralls_badge]: https://coveralls.io/repos/activeadmin-plugins/active_admin_import/badge.svg
|
97
|
+
[coveralls_link]: https://coveralls.io/github/activeadmin-plugins/active_admin_import
|
98
|
+
[codeclimate_badge]: https://codeclimate.com/github/activeadmin-plugins/active_admin_import/badges/gpa.svg
|
99
|
+
[codeclimate_link]: https://codeclimate.com/github/activeadmin-plugins/active_admin_import
|
100
|
+
[rubygems_badge]: https://badge.fury.io/rb/active_admin_import.svg
|
101
|
+
[rubygems_link]: https://rubygems.org/gems/active_admin_import
|
102
|
+
[license_badge]: http://img.shields.io/:license-mit-blue.svg
|
103
|
+
[license_link]: http://Fivell.mit-license.org
|
104
|
+
|
99
105
|
|
100
106
|
## Contributing
|
101
107
|
|
data/active_admin_import.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.name = 'active_admin_import'
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
gem.version = ActiveAdminImport::VERSION
|
18
|
-
gem.add_runtime_dependency 'activerecord-import', '~> 0.
|
18
|
+
gem.add_runtime_dependency 'activerecord-import', '~> 0.27'
|
19
19
|
gem.add_runtime_dependency 'rchardet', '~> 1.6'
|
20
20
|
gem.add_runtime_dependency 'rubyzip', '~> 1.2'
|
21
21
|
gem.add_dependency 'activeadmin', '>= 1.0.0.pre2'
|
@@ -8,6 +8,7 @@ module ActiveAdminImport
|
|
8
8
|
OPTIONS = [
|
9
9
|
:validate,
|
10
10
|
:on_duplicate_key_update,
|
11
|
+
:on_duplicate_key_ignore,
|
11
12
|
:ignore,
|
12
13
|
:timestamps,
|
13
14
|
:before_import,
|
@@ -48,7 +49,16 @@ module ActiveAdminImport
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def import_options
|
51
|
-
@import_options ||= options.slice(
|
52
|
+
@import_options ||= options.slice(
|
53
|
+
:validate,
|
54
|
+
:validate_uniqueness,
|
55
|
+
:on_duplicate_key_update,
|
56
|
+
:on_duplicate_key_ignore,
|
57
|
+
:ignore,
|
58
|
+
:timestamps,
|
59
|
+
:batch_transaction,
|
60
|
+
:batch_size
|
61
|
+
)
|
52
62
|
end
|
53
63
|
|
54
64
|
def batch_replace(header_key, options)
|
@@ -134,7 +144,10 @@ module ActiveAdminImport
|
|
134
144
|
end
|
135
145
|
|
136
146
|
def assign_options(options)
|
137
|
-
@options = {
|
147
|
+
@options = {
|
148
|
+
batch_size: 1000,
|
149
|
+
validate_uniqueness: true
|
150
|
+
}.merge(options.slice(*OPTIONS))
|
138
151
|
detect_csv_options
|
139
152
|
end
|
140
153
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Fedoronchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-import
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.27'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.27'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rchardet
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|