ntq_excelsior 1.3.0 → 1.4.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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/ntq_excelsior/exporter.rb +12 -2
- 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: b6a5e24a80fa3a23cb825780ed3d507a35fd431c17fc6bf0cebef21136bd76b4
|
4
|
+
data.tar.gz: 1a82ce13bfcb6fa6cee43183506c971f5f5c603dc2c7889c4c9cec75de87f584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc0f3a348f3287e7853f7dd5e95a50ec36814b99a51b32a2e296a086512e69ac09febc3e6ce0eaf1ba25c910b498e65d09693b1bca8c5ae7cf66c551d6d3cc72
|
7
|
+
data.tar.gz: '0481f21e47076aba37d617814989d18735977edf0d78f74542b1791ab6a91a09ae891c4695a38e516c97692b737a39ac085c270cced400c5af2324f82a14dbb5'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -77,7 +77,7 @@ class UserExporter < NtqExcelsior::Exporter
|
|
77
77
|
{
|
78
78
|
title: 'Active',
|
79
79
|
resolve: -> (record) { record.active ? 'Oui' : 'Non' }
|
80
|
-
# See axlsx example
|
80
|
+
# See axlsx example at https://github.com/caxlsx/caxlsx/blob/master/examples/list_validation_example.md for more options
|
81
81
|
list: {
|
82
82
|
options: ['Oui', 'Non'],
|
83
83
|
show_error_message: true,
|
@@ -4,6 +4,7 @@ module NtqExcelsior
|
|
4
4
|
class Exporter
|
5
5
|
attr_accessor :data
|
6
6
|
attr_accessor :context
|
7
|
+
attr_accessor :progression_tracker
|
7
8
|
|
8
9
|
DEFAULT_STYLES = {
|
9
10
|
date_format: {
|
@@ -36,6 +37,7 @@ module NtqExcelsior
|
|
36
37
|
|
37
38
|
def initialize(data)
|
38
39
|
@data = data
|
40
|
+
@data_count = data.size.to_d
|
39
41
|
end
|
40
42
|
|
41
43
|
def schema
|
@@ -232,15 +234,19 @@ module NtqExcelsior
|
|
232
234
|
end
|
233
235
|
index += 1
|
234
236
|
content[:rows] << resolve_header_row(schema[:columns], index)
|
235
|
-
@data.
|
237
|
+
@data.each_with_index do |record, index|
|
236
238
|
index += 1
|
239
|
+
if progression_tracker&.is_a?(Proc)
|
240
|
+
at = ((((index + 1).to_d / @data_count) * 100.to_d) / 2).round(2)
|
241
|
+
progression_tracker.call(at) if at % 5 == 0
|
242
|
+
end
|
237
243
|
content[:rows] << resolve_record_row(schema[:columns], record, index)
|
238
244
|
end
|
239
245
|
content
|
240
246
|
end
|
241
247
|
|
242
248
|
def add_sheet_content(content, wb_styles, sheet)
|
243
|
-
content[:rows].
|
249
|
+
content[:rows].each_with_index do |row, index|
|
244
250
|
row_style = []
|
245
251
|
if row[:styles].is_a?(Array) && row[:styles].any?
|
246
252
|
row[:styles].each do |style|
|
@@ -248,6 +254,10 @@ module NtqExcelsior
|
|
248
254
|
end
|
249
255
|
end
|
250
256
|
sheet.add_row row[:values], style: row_style, height: row[:height], types: row[:types]
|
257
|
+
if progression_tracker&.is_a?(Proc)
|
258
|
+
at = 50 + ((((index + 1).to_d / @data_count) * 100.to_d) / 2).round(2)
|
259
|
+
progression_tracker.call(at) if at % 5 == 0 || index == content[:rows].length - 1
|
260
|
+
end
|
251
261
|
if row[:data_validations]
|
252
262
|
row[:data_validations].each do |validation|
|
253
263
|
sheet.add_data_validation(validation[:range], validation[:config])
|
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
|
+
version: 1.4.0
|
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-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx
|