rails_admin_import 1.0.0 → 1.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 +26 -6
- data/README.md +6 -4
- data/lib/rails_admin_import/config.rb +2 -0
- data/lib/rails_admin_import/formats/csv_importer.rb +12 -7
- data/lib/rails_admin_import/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a37478fcdb96c3cddb93ac6f85dc1fa43329f32
|
4
|
+
data.tar.gz: 8b36ca27a1b441bebd19a6cb3a80865063975160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 037159e831272b29da9d07093f43fdb7e212ce92f4a28c02c7bc836b634239d4285e04f6fe102a6f402203644d4d81bc67388e7b75c1518674d63fb26eda6b49
|
7
|
+
data.tar.gz: c323b72bfd8d3980e11e06eadf83b34c184fcf3fd04d8ed73880dc45741d518b0d37cd0dcc37f698df1d64055e634e94c67db4797e81a652af84f428f7bc754a
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [1.1.0] - 2015-08-04
|
4
|
+
### Changed
|
5
|
+
- `csv_options` config added. Thanks Maksim Burnin!
|
6
|
+
|
7
|
+
## [1.0.0] - 2015-06-09
|
8
|
+
### Changed
|
9
|
+
|
10
|
+
Major rework of the gem by new maintainer.
|
11
|
+
|
12
|
+
- Support for Mongoid
|
13
|
+
- Changed model import hooks to take 1 hash argument
|
14
|
+
- Use Rails Admin abstract model instead of ActiveRecord reflection for better compatibility with custom associations
|
15
|
+
- Support CSV and JSON
|
16
|
+
- Update styling for Bootstrap 3
|
17
|
+
- Added tests
|
18
|
+
|
19
|
+
|
20
|
+
## [0.1.9] - 2014-05-22
|
21
|
+
### Changed
|
22
|
+
|
23
|
+
- Updated/corrected README
|
24
|
+
- Merged ImportLogger work
|
25
|
+
- Merged modifications to import view
|
26
|
+
- Merged post save hook on models
|
data/README.md
CHANGED
@@ -85,6 +85,8 @@ The file must be an array or an object with a root key the same name as the plur
|
|
85
85
|
|
86
86
|
* __header_converter__ (default `nil`): a lambda to convert each CSV header text string to a model attribute name. The default header converter converts to lowercase and replaces spaces with underscores.
|
87
87
|
|
88
|
+
* __csv_options__ (default `{}`): a hash of options that will be passed to a new [CSV](http://ruby-doc.org/stdlib-2.0.0/libdoc/csv/rdoc/CSV.html) instance
|
89
|
+
|
88
90
|
### Model-specific configuration
|
89
91
|
|
90
92
|
Use [standard RailsAdmin DSL](https://github.com/sferik/rails_admin/wiki/Railsadmin-DSL) to add or remove fields.
|
@@ -150,11 +152,11 @@ Define instance methods on your models to be hooked into the import process, if
|
|
150
152
|
# some model
|
151
153
|
class User < ActiveRecord::Base
|
152
154
|
def before_import_save(record)
|
153
|
-
# Your custom special sauce
|
155
|
+
# Your custom special sauce
|
154
156
|
end
|
155
157
|
|
156
158
|
def after_import_save(record)
|
157
|
-
# Your custom special sauce
|
159
|
+
# Your custom special sauce
|
158
160
|
end
|
159
161
|
end
|
160
162
|
```
|
@@ -190,10 +192,10 @@ Support for Mongoid is early, so if you can suggest improvements (especially aro
|
|
190
192
|
1. Clone the repository to your machine
|
191
193
|
|
192
194
|
git clone https://github.com/stephskardal/rails_admin_import
|
193
|
-
|
195
|
+
|
194
196
|
2. Run `bundle install`
|
195
197
|
3. Run `rspec`
|
196
|
-
|
198
|
+
|
197
199
|
The structure of the tests is taken from the Rails Admin gem.
|
198
200
|
|
199
201
|
## Authors
|
@@ -7,6 +7,7 @@ module RailsAdminImport
|
|
7
7
|
attr_accessor :line_item_limit
|
8
8
|
attr_accessor :rollback_on_error
|
9
9
|
attr_accessor :header_converter
|
10
|
+
attr_accessor :csv_options
|
10
11
|
|
11
12
|
def model(model_name, &block)
|
12
13
|
unless @deprecation_shown
|
@@ -26,6 +27,7 @@ module RailsAdminImport
|
|
26
27
|
@line_item_limit = 1000
|
27
28
|
@rollback_on_error = false
|
28
29
|
@header_converter = nil
|
30
|
+
@csv_options = {}
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -27,15 +27,17 @@ module RailsAdminImport
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def csv_options
|
30
|
-
|
30
|
+
defaults = RailsAdminImport.config.csv_options
|
31
|
+
options = {
|
31
32
|
headers: true,
|
32
|
-
header_converters: @header_converter
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
header_converters: @header_converter,
|
34
|
+
encoding: encoding,
|
35
|
+
}
|
36
|
+
|
37
|
+
defaults.merge(options)
|
36
38
|
end
|
37
39
|
|
38
|
-
def
|
40
|
+
def encoding
|
39
41
|
from_encoding =
|
40
42
|
if !@encoding.blank?
|
41
43
|
@encoding
|
@@ -44,8 +46,11 @@ module RailsAdminImport
|
|
44
46
|
end
|
45
47
|
|
46
48
|
to_encoding = import_model.abstract_model.encoding
|
49
|
+
|
47
50
|
if from_encoding && from_encoding != to_encoding
|
48
|
-
|
51
|
+
"#{from_encoding}:#{to_encoding}"
|
52
|
+
else
|
53
|
+
nil
|
49
54
|
end
|
50
55
|
end
|
51
56
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steph Skardal
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -124,3 +124,4 @@ signing_key:
|
|
124
124
|
specification_version: 4
|
125
125
|
summary: Import functionality for Rails Admin
|
126
126
|
test_files: []
|
127
|
+
has_rdoc:
|