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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a4efa937725b46c65a0ed4b23ebba4a10dc359835b6e7b563c2c7d7fa269404
4
- data.tar.gz: a65826c126a6e9485dbb8227a439960a944ed4481138dca5bb2b5598db9d2490
3
+ metadata.gz: b6a5e24a80fa3a23cb825780ed3d507a35fd431c17fc6bf0cebef21136bd76b4
4
+ data.tar.gz: 1a82ce13bfcb6fa6cee43183506c971f5f5c603dc2c7889c4c9cec75de87f584
5
5
  SHA512:
6
- metadata.gz: d70936785c973e0d76ecb3d26ab0e676acfaa09c6c69e8bf7902a9b3c31608a8b81deef35ffb593ffbe0fbdeff76b04a9296ac757ccd7d5788a8c5059b4d7403
7
- data.tar.gz: 5cb1daf2aef2b3829275277184af5bef789b73a33c2fc8e60ae5b4e4efc09db3f71591241ab6975417c2074d6cb82a622a33bd924b4742cb5b9f4b7400e567a9
6
+ metadata.gz: fc0f3a348f3287e7853f7dd5e95a50ec36814b99a51b32a2e296a086512e69ac09febc3e6ce0eaf1ba25c910b498e65d09693b1bca8c5ae7cf66c551d6d3cc72
7
+ data.tar.gz: '0481f21e47076aba37d617814989d18735977edf0d78f74542b1791ab6a91a09ae891c4695a38e516c97692b737a39ac085c270cced400c5af2324f82a14dbb5'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ntq_excelsior (1.3.0)
4
+ ntq_excelsior (1.4.0)
5
5
  caxlsx (< 4)
6
6
  roo (< 3)
7
7
 
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 [here](https://github.com/caxlsx/caxlsx/blob/master/examples/list_validation_example.md) for more options
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.each do |record|
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].each do |row|
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])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NtqExcelsior
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  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: 1.3.0
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-02-01 00:00:00.000000000 Z
11
+ date: 2024-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caxlsx