csv_step_importer 0.8.1 → 0.9.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 +36 -0
- data/Gemfile.lock +43 -39
- data/csv_step_importer.gemspec +1 -0
- data/lib/csv_step_importer/file.rb +36 -13
- data/lib/csv_step_importer/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5334af91a76293f6cc7b57226bbfd80cb6fdd28a4577f25189cb922ed002647e
|
|
4
|
+
data.tar.gz: 6e2166c2764d07b088b7f11ee94d030f42692553635cc9b38aa4a427528d8ef1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90b7fca64a184012605cb7e4963425d3e77add0c17798af72466a08ff5aa9140b45f4c413e29848472a19629a90d1ad0f35338f9ab3d30aaaebcfab449251119
|
|
7
|
+
data.tar.gz: 48a5f1ebdd26df973c272a5a5262cb69fdad6f69b6bc4bb231003f035acb059ea291165999ba158474112666fff7383a75b0a5e3f9807dcf0f1976bbe4ec8f72
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
## 2018-08-22 Version 0.9.0
|
|
13
|
+
### Added
|
|
14
|
+
- Add csv_option headers_mode
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
headers_mode is a enum with which you can control how headers will be transformed during the file read.
|
|
18
|
+
|
|
19
|
+
Note, that this option will be applied, after the csv_option headers is processed.
|
|
20
|
+
|
|
21
|
+
The following values are allowed:
|
|
22
|
+
case_sensitive_symbols:
|
|
23
|
+
"A z" becomes :A_z
|
|
24
|
+
|
|
25
|
+
case_insensitive_symbols:
|
|
26
|
+
"A z" becomes :a_z
|
|
27
|
+
|
|
28
|
+
symbols:
|
|
29
|
+
"A z" becomes :"A z"
|
|
30
|
+
|
|
31
|
+
preserve:
|
|
32
|
+
"A z" will stay "A z"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Deprecated csv_option case_sensitive_headers
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
csv_step_importer (0.
|
|
4
|
+
csv_step_importer (0.9.0)
|
|
5
5
|
activemodel
|
|
6
6
|
activerecord-import
|
|
7
7
|
activesupport
|
|
@@ -10,28 +10,28 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
actionpack (5.2.
|
|
14
|
-
actionview (= 5.2.
|
|
15
|
-
activesupport (= 5.2.
|
|
13
|
+
actionpack (5.2.1)
|
|
14
|
+
actionview (= 5.2.1)
|
|
15
|
+
activesupport (= 5.2.1)
|
|
16
16
|
rack (~> 2.0)
|
|
17
17
|
rack-test (>= 0.6.3)
|
|
18
18
|
rails-dom-testing (~> 2.0)
|
|
19
19
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
20
|
-
actionview (5.2.
|
|
21
|
-
activesupport (= 5.2.
|
|
20
|
+
actionview (5.2.1)
|
|
21
|
+
activesupport (= 5.2.1)
|
|
22
22
|
builder (~> 3.1)
|
|
23
23
|
erubi (~> 1.4)
|
|
24
24
|
rails-dom-testing (~> 2.0)
|
|
25
25
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
26
|
-
activemodel (5.2.
|
|
27
|
-
activesupport (= 5.2.
|
|
28
|
-
activerecord (5.2.
|
|
29
|
-
activemodel (= 5.2.
|
|
30
|
-
activesupport (= 5.2.
|
|
26
|
+
activemodel (5.2.1)
|
|
27
|
+
activesupport (= 5.2.1)
|
|
28
|
+
activerecord (5.2.1)
|
|
29
|
+
activemodel (= 5.2.1)
|
|
30
|
+
activesupport (= 5.2.1)
|
|
31
31
|
arel (>= 9.0)
|
|
32
|
-
activerecord-import (0.
|
|
32
|
+
activerecord-import (0.25.0)
|
|
33
33
|
activerecord (>= 3.2)
|
|
34
|
-
activesupport (5.2.
|
|
34
|
+
activesupport (5.2.1)
|
|
35
35
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
36
36
|
i18n (>= 0.7, < 2)
|
|
37
37
|
minitest (~> 5.1)
|
|
@@ -43,7 +43,7 @@ GEM
|
|
|
43
43
|
crass (1.0.4)
|
|
44
44
|
diff-lcs (1.3)
|
|
45
45
|
erubi (1.7.1)
|
|
46
|
-
i18n (1.0
|
|
46
|
+
i18n (1.1.0)
|
|
47
47
|
concurrent-ruby (~> 1.0)
|
|
48
48
|
jaro_winkler (1.5.1)
|
|
49
49
|
loofah (2.2.2)
|
|
@@ -52,56 +52,59 @@ GEM
|
|
|
52
52
|
method_source (0.9.0)
|
|
53
53
|
mini_portile2 (2.3.0)
|
|
54
54
|
minitest (5.11.3)
|
|
55
|
-
nokogiri (1.8.
|
|
55
|
+
nokogiri (1.8.4)
|
|
56
56
|
mini_portile2 (~> 2.3.0)
|
|
57
57
|
parallel (1.12.1)
|
|
58
|
-
parser (2.5.1.
|
|
58
|
+
parser (2.5.1.2)
|
|
59
59
|
ast (~> 2.4.0)
|
|
60
60
|
powerpack (0.1.2)
|
|
61
61
|
rack (2.0.5)
|
|
62
|
-
rack-test (1.
|
|
62
|
+
rack-test (1.1.0)
|
|
63
63
|
rack (>= 1.0, < 3)
|
|
64
64
|
rails-dom-testing (2.0.3)
|
|
65
65
|
activesupport (>= 4.2.0)
|
|
66
66
|
nokogiri (>= 1.6)
|
|
67
67
|
rails-html-sanitizer (1.0.4)
|
|
68
68
|
loofah (~> 2.2, >= 2.2.2)
|
|
69
|
-
railties (5.2.
|
|
70
|
-
actionpack (= 5.2.
|
|
71
|
-
activesupport (= 5.2.
|
|
69
|
+
railties (5.2.1)
|
|
70
|
+
actionpack (= 5.2.1)
|
|
71
|
+
activesupport (= 5.2.1)
|
|
72
72
|
method_source
|
|
73
73
|
rake (>= 0.8.7)
|
|
74
|
-
thor (>= 0.
|
|
74
|
+
thor (>= 0.19.0, < 2.0)
|
|
75
75
|
rainbow (3.0.0)
|
|
76
76
|
rake (10.5.0)
|
|
77
|
-
rspec (3.
|
|
78
|
-
rspec-core (~> 3.
|
|
79
|
-
rspec-expectations (~> 3.
|
|
80
|
-
rspec-mocks (~> 3.
|
|
81
|
-
rspec-core (3.
|
|
82
|
-
rspec-support (~> 3.
|
|
83
|
-
rspec-expectations (3.
|
|
77
|
+
rspec (3.8.0)
|
|
78
|
+
rspec-core (~> 3.8.0)
|
|
79
|
+
rspec-expectations (~> 3.8.0)
|
|
80
|
+
rspec-mocks (~> 3.8.0)
|
|
81
|
+
rspec-core (3.8.0)
|
|
82
|
+
rspec-support (~> 3.8.0)
|
|
83
|
+
rspec-expectations (3.8.1)
|
|
84
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
85
|
-
rspec-support (~> 3.
|
|
86
|
-
rspec-mocks (3.
|
|
85
|
+
rspec-support (~> 3.8.0)
|
|
86
|
+
rspec-mocks (3.8.0)
|
|
87
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
88
|
-
rspec-support (~> 3.
|
|
89
|
-
rspec-support (3.
|
|
90
|
-
rubocop (0.
|
|
88
|
+
rspec-support (~> 3.8.0)
|
|
89
|
+
rspec-support (3.8.0)
|
|
90
|
+
rubocop (0.58.2)
|
|
91
91
|
jaro_winkler (~> 1.5.1)
|
|
92
92
|
parallel (~> 1.10)
|
|
93
|
-
parser (>= 2.5)
|
|
93
|
+
parser (>= 2.5, != 2.5.1.1)
|
|
94
94
|
powerpack (~> 0.1)
|
|
95
95
|
rainbow (>= 2.2.2, < 4.0)
|
|
96
96
|
ruby-progressbar (~> 1.7)
|
|
97
97
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
98
|
-
rubocop-rails (1.
|
|
98
|
+
rubocop-rails (1.5.0)
|
|
99
99
|
railties (>= 3.0)
|
|
100
100
|
rubocop (~> 0.53)
|
|
101
|
-
rubocop-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
rubocop-rails_config (0.2.3)
|
|
102
|
+
railties (>= 3.0)
|
|
103
|
+
rubocop (~> 0.56)
|
|
104
|
+
rubocop-rspec (1.28.0)
|
|
105
|
+
rubocop (>= 0.58.0)
|
|
106
|
+
ruby-progressbar (1.10.0)
|
|
107
|
+
smarter_csv (1.2.4)
|
|
105
108
|
thor (0.20.0)
|
|
106
109
|
thread_safe (0.3.6)
|
|
107
110
|
tzinfo (1.2.5)
|
|
@@ -117,6 +120,7 @@ DEPENDENCIES
|
|
|
117
120
|
rake (~> 10.0)
|
|
118
121
|
rspec (~> 3.0)
|
|
119
122
|
rubocop-rails
|
|
123
|
+
rubocop-rails_config
|
|
120
124
|
rubocop-rspec
|
|
121
125
|
|
|
122
126
|
BUNDLED WITH
|
data/csv_step_importer.gemspec
CHANGED
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
spec.add_development_dependency "bundler", "~> 1.16"
|
|
36
36
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
37
37
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
38
|
+
spec.add_development_dependency "rubocop-rails_config"
|
|
38
39
|
spec.add_development_dependency "rubocop-rails"
|
|
39
40
|
spec.add_development_dependency "rubocop-rspec"
|
|
40
41
|
|
|
@@ -73,17 +73,6 @@ module CSVStepImporter
|
|
|
73
73
|
}
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
def keys_as_symbols(case_sensitive: false)
|
|
77
|
-
if case_sensitive
|
|
78
|
-
Proc.new { |headers|
|
|
79
|
-
headers.map { |x| x.strip.gsub(%r{"}, '').gsub(/(\s|\-)+/, '_').to_sym }
|
|
80
|
-
}
|
|
81
|
-
else
|
|
82
|
-
# use existing helper
|
|
83
|
-
:keys_as_symbols
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
76
|
def precompile_csv_options!
|
|
88
77
|
# set default options
|
|
89
78
|
self.csv_options = {
|
|
@@ -92,19 +81,53 @@ module CSVStepImporter
|
|
|
92
81
|
}.merge(csv_options)
|
|
93
82
|
|
|
94
83
|
# easier specification of headers, including case case sensitive headers
|
|
95
|
-
if csv_options[:headers] || csv_options[:case_sensitive_headers]
|
|
84
|
+
if csv_options[:headers] || csv_options[:headers_mode] || csv_options[:case_sensitive_headers]
|
|
96
85
|
if csv_options[:header_transformations]
|
|
97
86
|
raise "either use header_transformations or headers (and case_sensitive_headers optionally)"
|
|
98
87
|
end
|
|
99
88
|
|
|
100
89
|
csv_options[:header_transformations] = [ :none ]
|
|
101
90
|
csv_options[:header_transformations] << { key_mapping: csv_options.delete(:headers) } if csv_options[:headers]
|
|
102
|
-
csv_options[:header_transformations] <<
|
|
91
|
+
csv_options[:header_transformations] << header_mode_transformer
|
|
103
92
|
end
|
|
104
93
|
|
|
105
94
|
# retrieve headers from CSV
|
|
106
95
|
csv_options[:header_transformations] ||= []
|
|
107
96
|
csv_options[:header_transformations] << header_proc
|
|
108
97
|
end
|
|
98
|
+
|
|
99
|
+
def header_mode_transformer
|
|
100
|
+
case headers_mode
|
|
101
|
+
when :case_sensitive_symbols
|
|
102
|
+
Proc.new { |headers|
|
|
103
|
+
headers.map { |x| x.strip.gsub(%r{"}, "").gsub(/(\s|\-)+/, "_").to_sym }
|
|
104
|
+
}
|
|
105
|
+
when :case_insensitive_symbols
|
|
106
|
+
# use existing helper
|
|
107
|
+
:keys_as_symbols
|
|
108
|
+
when :preserve
|
|
109
|
+
Proc.new { |headers| headers }
|
|
110
|
+
else
|
|
111
|
+
raise "unknown headers_mode #{headers_mode}"
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def headers_mode
|
|
116
|
+
if csv_options[:case_sensitive_headers]
|
|
117
|
+
ActiveSupport::Deprecation.warn(
|
|
118
|
+
"Key `:case_sensitive_headers` is deprecated, please use `:headers_mode` with a value of" +
|
|
119
|
+
" `:case_sensitive_symbols` instead"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
if csv_options[:headers_mode]
|
|
123
|
+
raise "Key `:case_sensitive_headers` is deprecated, and will be ignored, since headers_mode is specified"
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
csv_options.delete(:case_sensitive_headers)
|
|
127
|
+
csv_options[:headers_mode] = :case_sensitive_symbols
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
csv_options[:headers_mode] || :preserve
|
|
131
|
+
end
|
|
109
132
|
end
|
|
110
133
|
end
|
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.
|
|
4
|
+
version: 0.9.0
|
|
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-08-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop-rails_config
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rubocop-rails
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -147,6 +161,7 @@ files:
|
|
|
147
161
|
- ".rspec"
|
|
148
162
|
- ".rubocop.yml"
|
|
149
163
|
- ".travis.yml"
|
|
164
|
+
- CHANGELOG.md
|
|
150
165
|
- CODE_OF_CONDUCT.md
|
|
151
166
|
- Gemfile
|
|
152
167
|
- Gemfile.lock
|