csv_step_importer 0.7.4 → 0.7.5
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/Gemfile.lock +11 -9
- data/README.md +2 -0
- data/lib/csv_step_importer/file.rb +13 -2
- data/lib/csv_step_importer/model/dao.rb +1 -1
- data/lib/csv_step_importer/model/importable_model.rb +6 -2
- data/lib/csv_step_importer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96a84016e041d144dc81796ae295e23d934305f722bd03cb88dc574cbbd460ca
|
4
|
+
data.tar.gz: 24d5229cdbe01cacf8ced8fc137a21334a10051ec0917801e83330401db778df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05ade3ead9a672dd14d214991e1e18f58ed739c479a4a2fe71f7de2c8ce22d41cf5bca5400733be2c637371f1fbf80ec01e013d2544e4534bd9377a49d07056e
|
7
|
+
data.tar.gz: d3a9b37b47bac1a099c0942de35f95df534fba5c87fc7fae082365733180f9f056c6982dd38f481d55814b993e795788460300b05be9ccaa9e1323e327d45f26
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
csv_step_importer (0.7.
|
4
|
+
csv_step_importer (0.7.5)
|
5
5
|
activemodel
|
6
6
|
activerecord-import
|
7
7
|
activesupport
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
activemodel (= 5.2.0)
|
30
30
|
activesupport (= 5.2.0)
|
31
31
|
arel (>= 9.0)
|
32
|
-
activerecord-import (0.
|
32
|
+
activerecord-import (0.24.0)
|
33
33
|
activerecord (>= 3.2)
|
34
34
|
activesupport (5.2.0)
|
35
35
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -45,18 +45,19 @@ GEM
|
|
45
45
|
erubi (1.7.1)
|
46
46
|
i18n (1.0.1)
|
47
47
|
concurrent-ruby (~> 1.0)
|
48
|
+
jaro_winkler (1.5.1)
|
48
49
|
loofah (2.2.2)
|
49
50
|
crass (~> 1.0.2)
|
50
51
|
nokogiri (>= 1.5.9)
|
51
52
|
method_source (0.9.0)
|
52
53
|
mini_portile2 (2.3.0)
|
53
54
|
minitest (5.11.3)
|
54
|
-
nokogiri (1.8.
|
55
|
+
nokogiri (1.8.3)
|
55
56
|
mini_portile2 (~> 2.3.0)
|
56
57
|
parallel (1.12.1)
|
57
58
|
parser (2.5.1.0)
|
58
59
|
ast (~> 2.4.0)
|
59
|
-
powerpack (0.1.
|
60
|
+
powerpack (0.1.2)
|
60
61
|
rack (2.0.5)
|
61
62
|
rack-test (1.0.0)
|
62
63
|
rack (>= 1.0, < 3)
|
@@ -86,7 +87,8 @@ GEM
|
|
86
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
87
88
|
rspec-support (~> 3.7.0)
|
88
89
|
rspec-support (3.7.1)
|
89
|
-
rubocop (0.
|
90
|
+
rubocop (0.57.2)
|
91
|
+
jaro_winkler (~> 1.5.1)
|
90
92
|
parallel (~> 1.10)
|
91
93
|
parser (>= 2.5)
|
92
94
|
powerpack (~> 0.1)
|
@@ -96,15 +98,15 @@ GEM
|
|
96
98
|
rubocop-rails (1.4.1)
|
97
99
|
railties (>= 3.0)
|
98
100
|
rubocop (~> 0.53)
|
99
|
-
rubocop-rspec (1.
|
100
|
-
rubocop (>= 0.
|
101
|
+
rubocop-rspec (1.27.0)
|
102
|
+
rubocop (>= 0.56.0)
|
101
103
|
ruby-progressbar (1.9.0)
|
102
104
|
smarter_csv (1.2.3)
|
103
105
|
thor (0.20.0)
|
104
106
|
thread_safe (0.3.6)
|
105
107
|
tzinfo (1.2.5)
|
106
108
|
thread_safe (~> 0.1)
|
107
|
-
unicode-display_width (1.
|
109
|
+
unicode-display_width (1.4.0)
|
108
110
|
|
109
111
|
PLATFORMS
|
110
112
|
ruby
|
@@ -118,4 +120,4 @@ DEPENDENCIES
|
|
118
120
|
rubocop-rspec
|
119
121
|
|
120
122
|
BUNDLED WITH
|
121
|
-
1.16.
|
123
|
+
1.16.2
|
data/README.md
CHANGED
@@ -35,8 +35,11 @@ module CSVStepImporter
|
|
35
35
|
|
36
36
|
first_row = 2
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
options = csv_options.deep_dup
|
39
|
+
options[:header_transformations] ||= []
|
40
|
+
options[:header_transformations] << header_proc
|
41
|
+
|
42
|
+
::SmarterCSV.process(path, **options) do |rows|
|
40
43
|
add_children chunk_class.new(
|
41
44
|
first_row: first_row,
|
42
45
|
parent: self,
|
@@ -67,5 +70,13 @@ module CSVStepImporter
|
|
67
70
|
return unless csv_load_error
|
68
71
|
errors[:csv_file] << I18n.t("csv_step_importer.errors.#{csv_load_error.class.name.underscore.gsub(/\//, '_')}")
|
69
72
|
end
|
73
|
+
|
74
|
+
private
|
75
|
+
def header_proc
|
76
|
+
Proc.new { |headers|
|
77
|
+
self.headers = headers
|
78
|
+
headers
|
79
|
+
}
|
80
|
+
end
|
70
81
|
end
|
71
82
|
end
|
@@ -17,27 +17,31 @@ module CSVStepImporter
|
|
17
17
|
CSVStepImporter::Model::Importer
|
18
18
|
end
|
19
19
|
|
20
|
-
#
|
20
|
+
# return CSVStepImporter::Model::Reflector in order to enable reflections (e.g. get ids of all rows)
|
21
|
+
# disabled by default
|
21
22
|
def reflector_class
|
22
|
-
# in order to enable reflections return reflector class: CSVStepImporter::Model::Reflector
|
23
23
|
nil
|
24
24
|
end
|
25
25
|
|
26
|
+
# NOTE: required only when reflector class is set
|
26
27
|
# example: env[:company].company_users
|
27
28
|
def finder_scope
|
28
29
|
model_class.all
|
29
30
|
end
|
30
31
|
|
32
|
+
# NOTE: required only when reflector class is set
|
31
33
|
# example: [:email]
|
32
34
|
def finder_keys
|
33
35
|
raise "please extend and implement"
|
34
36
|
end
|
35
37
|
|
38
|
+
# NOTE: required only when importer class is set
|
36
39
|
# see: https://github.com/zdennis/activerecord-import/wiki/On-Duplicate-Key-Update
|
37
40
|
def on_duplicate_key_ignore
|
38
41
|
false
|
39
42
|
end
|
40
43
|
|
44
|
+
# NOTE: required only when importer class is set
|
41
45
|
# example [:email, :updated_at]
|
42
46
|
# see: https://github.com/zdennis/activerecord-import/wiki/On-Duplicate-Key-Update
|
43
47
|
def on_duplicate_key_update
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_step_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian-Manuel Butzke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|