ntq_excelsior 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ntq_excelsior/context.rb +15 -0
- data/lib/ntq_excelsior/importer.rb +23 -3
- data/lib/ntq_excelsior/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2860934f0b20b6d7daf121020a2c297c3e56586428bd28656340af0e42bab96
|
4
|
+
data.tar.gz: 14b94f8385b15e3812a9c40daa7e8a8116c35a9e1cf6a8accf85887f3ce876bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5f7d219d75ded2020a1e92eeeb84536653e8f7ab419d91698c64acdf9809fbfbdd75e5f00c8db493eb8129c296341bab7885a71f1f8c34abb0fcb0485fd2061
|
7
|
+
data.tar.gz: 92061140c2a2f9b0072c39376ce1eec4cafcd3939df55e41db785b80262343c96406fd11d6bf0311c5f2fe05d5d03b56897754962e6d65caec2497d517ac8f50
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'roo'
|
2
|
+
require 'ntq_excelsior/context'
|
2
3
|
|
3
4
|
module NtqExcelsior
|
4
5
|
class Importer
|
5
|
-
attr_accessor :file, :check, :lines, :options, :status_tracker
|
6
|
+
attr_accessor :file, :check, :lines, :options, :status_tracker, :success
|
7
|
+
attr_reader :context
|
6
8
|
|
7
9
|
class << self
|
8
10
|
def autosave(value = nil)
|
@@ -29,6 +31,16 @@ module NtqExcelsior
|
|
29
31
|
@schema ||= value
|
30
32
|
end
|
31
33
|
|
34
|
+
def before(&block)
|
35
|
+
@before = block if block_given?
|
36
|
+
@before
|
37
|
+
end
|
38
|
+
|
39
|
+
def after(&block)
|
40
|
+
@after = block if block_given?
|
41
|
+
@after
|
42
|
+
end
|
43
|
+
|
32
44
|
def max_error_count(value = nil)
|
33
45
|
@max_error_count ||= value
|
34
46
|
end
|
@@ -42,6 +54,10 @@ module NtqExcelsior
|
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
57
|
+
def initialize
|
58
|
+
@context = NtqExcelsior::Context.new
|
59
|
+
end
|
60
|
+
|
45
61
|
def spreadsheet
|
46
62
|
return @spreadsheet unless @spreadsheet.nil?
|
47
63
|
|
@@ -134,7 +150,7 @@ module NtqExcelsior
|
|
134
150
|
def lines
|
135
151
|
return @lines if @lines
|
136
152
|
|
137
|
-
@lines = spreadsheet_data.map {|line| parse_line(line) }
|
153
|
+
@lines = spreadsheet_data.map { |line| parse_line(line) }
|
138
154
|
end
|
139
155
|
|
140
156
|
# id for default query in model
|
@@ -197,6 +213,7 @@ module NtqExcelsior
|
|
197
213
|
end
|
198
214
|
|
199
215
|
def import(save: true, status_tracker: nil)
|
216
|
+
self.class.before.call(@context, options) if self.class.before.is_a?(Proc)
|
200
217
|
at = 0
|
201
218
|
errors_lines = []
|
202
219
|
success_count = 0
|
@@ -222,7 +239,10 @@ module NtqExcelsior
|
|
222
239
|
end
|
223
240
|
end
|
224
241
|
|
225
|
-
{ success_count: success_count, not_found_count: not_found_count, errors: errors_lines }
|
242
|
+
import_stats = { success_count: success_count, not_found_count: not_found_count, errors: errors_lines }
|
243
|
+
@context.success = true if errors_lines.empty?
|
244
|
+
self.class.after.call(@context, options) if self.class.after.is_a?(Proc)
|
245
|
+
import_stats
|
226
246
|
end
|
227
247
|
|
228
248
|
private
|
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: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- README.md
|
57
57
|
- Rakefile
|
58
58
|
- lib/ntq_excelsior.rb
|
59
|
+
- lib/ntq_excelsior/context.rb
|
59
60
|
- lib/ntq_excelsior/exporter.rb
|
60
61
|
- lib/ntq_excelsior/importer.rb
|
61
62
|
- lib/ntq_excelsior/multi_workbook_exporter.rb
|