ntq_excelsior 0.5.1 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/ntq_excelsior/exporter.rb +1 -1
- data/lib/ntq_excelsior/importer.rb +10 -5
- data/lib/ntq_excelsior/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: c83e96aa4574d61fab90bd411335709ee1bfc7553866b9a622921d1e8a9d23df
|
4
|
+
data.tar.gz: 45ed1db546080412b594bb3e2af1d5ec0f15df57bb80c65f7d51d6a86ca1627b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5a6cde69fea2f857b25090b68fdd3b7055646a341a4be7b9a53428ca2f318234c708199da2e678a65d2703c6dc28384eb51416eeba611a4efae12e829dff8cc
|
7
|
+
data.tar.gz: 99be33b0725e28427bc973a293429a19cd4d89669f397bd96ae74a209233e6e0529f2cf1c249c6936a8c14d5648abf400fdf4e762d5faee9838144a431e0518e
|
data/README.md
CHANGED
@@ -45,6 +45,7 @@ class UserExporter < NtqExcelsior::Exporter
|
|
45
45
|
},
|
46
46
|
{
|
47
47
|
title: 'Email',
|
48
|
+
header_styles: [:blue],
|
48
49
|
resolve: 'email'
|
49
50
|
},
|
50
51
|
{
|
@@ -91,6 +92,8 @@ class UserImporter < NtqExcelsior::Importer
|
|
91
92
|
|
92
93
|
primary_key :email
|
93
94
|
|
95
|
+
## if set to save, the record will not be save automatically after import_line
|
96
|
+
## Errors have to be added to the @errors hash manually
|
94
97
|
# autosave false
|
95
98
|
|
96
99
|
structure [{
|
@@ -99,7 +99,7 @@ module NtqExcelsior
|
|
99
99
|
headers.each do |header|
|
100
100
|
width = header[:width] || 1
|
101
101
|
row[:values] << header[:title] || ''
|
102
|
-
row[:styles] << get_styles(header[:styles])
|
102
|
+
row[:styles] << get_styles(header[:header_styles] || header[:styles])
|
103
103
|
if width > 1
|
104
104
|
colspan = width - 1
|
105
105
|
row[:values].push(*Array.new(colspan, nil))
|
@@ -144,11 +144,13 @@ module NtqExcelsior
|
|
144
144
|
|
145
145
|
def import_line(line, save: true)
|
146
146
|
record = find_or_initialize_record(line)
|
147
|
+
return { status: :not_found } unless record
|
148
|
+
|
147
149
|
@success = false
|
148
150
|
@action = nil
|
149
151
|
@errors = []
|
150
152
|
|
151
|
-
if (
|
153
|
+
if (self.class.autoset)
|
152
154
|
record = set_record_fields(record, line)
|
153
155
|
end
|
154
156
|
|
@@ -173,11 +175,14 @@ module NtqExcelsior
|
|
173
175
|
at = 0
|
174
176
|
errors_lines = []
|
175
177
|
success_count = 0
|
178
|
+
not_found_count = 0
|
176
179
|
lines.each_with_index do |line, index|
|
177
|
-
break if errors_lines.size == self.class.max_error_count
|
180
|
+
break if errors_lines.size == self.class.max_error_count
|
178
181
|
|
179
182
|
result = import_line(line.with_indifferent_access, save: true)
|
180
183
|
case result[:status]
|
184
|
+
when :not_found
|
185
|
+
not_found_count += 1
|
181
186
|
when :success
|
182
187
|
success_count += 1
|
183
188
|
when :error
|
@@ -188,12 +193,12 @@ module NtqExcelsior
|
|
188
193
|
|
189
194
|
if @status_tracker&.is_a?(Proc)
|
190
195
|
at = (((index + 1).to_d / lines.size) * 100.to_d)
|
191
|
-
@status_tracker.call(at)
|
196
|
+
@status_tracker.call(at)
|
192
197
|
end
|
193
198
|
end
|
194
199
|
|
195
|
-
{ success_count: success_count, errors: errors_lines }
|
200
|
+
{ success_count: success_count, not_found_count: not_found_count, errors: errors_lines }
|
196
201
|
end
|
197
202
|
|
198
203
|
end
|
199
|
-
end
|
204
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntq_excelsior
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx
|