ndr_import 11.6.0 → 11.7.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: 0f7ea78a292f3c2ee622bda06d341329c97af0dd0edd36c039ee349a08b74284
4
- data.tar.gz: 1dae1db120f401a1cfb85b5d243563fd9ba26f290b313d561d4b6b3327b732b8
3
+ metadata.gz: 42a13d9464123749bb78650658d058a47b23f59c75d611c2bebe127a056e705c
4
+ data.tar.gz: ba30f77ba569506765a14d514e0b021a9d30a0f097fab18b38dc002ff6c53634
5
5
  SHA512:
6
- metadata.gz: bb20b9455c14347bd9ce894858693f94f3c7d8d3fa2c2eac390bb948011db5ae1001513ce6654cca1ca2bdbad40cf5dbd5e6c3bb491def911893159447f7fbe9
7
- data.tar.gz: 5683e42c10156785a8e58f13269250f59f90c81ca46613840e405f6f7e6c80a7f203e3ccdb4b49fef0eeb1d300394f5120464cb5d5bd193950505f6f36365281
6
+ metadata.gz: 94ac6dd14da96864fb812129036ee81a2715fef3b464279e43341434f4a70cf82142a89abbc324d0b9ce6a9a784e89c60422c5a6176073b635b49997977ad4e2
7
+ data.tar.gz: 56b8b030cea738fdf43e654cc91251a5eefd7a6ee3b58e5482d4c6a8cc8a1484b48a9a2e04ba84f80599f67725400e93d3aae3533ee617b141069dc18b443886
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ## [Unreleased]
2
2
  * no unreleased changes
3
3
 
4
+ ## 11.7.0 / 2026-09-24
5
+ ### Added
6
+ * Added the ability to define a virtual :filename column
7
+
4
8
  ## 11.6.0 / 2026-09-08
5
9
  ### Fixed
6
10
  * `NdrImport::File::SevenZip` was extracting files one directory level too deep
@@ -237,7 +237,10 @@ module NdrImport
237
237
 
238
238
  # returns the column names as we expect to receive them
239
239
  def column_names(column_mappings)
240
- column_mappings.map { |c| (c['column'] || c['standard_mapping']).try(:downcase) }
240
+ column_mappings.map do |c|
241
+ name = c['column'] || c['standard_mapping']
242
+ name.to_s.downcase unless name.is_a?(Regexp)
243
+ end
241
244
  end
242
245
 
243
246
  # If specified in the mapping, stop transforming data at a given index (column)
@@ -83,7 +83,28 @@ module NdrImport
83
83
  # Merge file_metadata (from VCF or XML) with directly assigned table_metadata
84
84
  # to form `table_metadata`
85
85
  mapping.table_metadata = (mapping.table_metadata || {}).merge(file_metadata || {})
86
- yield(mapping, table_content)
86
+
87
+ augmented_table_content = filename_augmented_rows(mapping, table_content, filename)
88
+
89
+ yield(mapping, augmented_table_content)
90
+ end
91
+ end
92
+
93
+ def filename_augmented_rows(table, rows, filename)
94
+ return enum_for(:filename_augmented_rows, table, rows, filename) unless block_given?
95
+
96
+ filename_column_position = table.columns.index { |c| c['column'] == :filename }
97
+
98
+ rows.each.with_index do |row, i|
99
+ if filename_column_position
100
+ if i < table.header_lines
101
+ row.insert(filename_column_position, :filename)
102
+ else
103
+ row.insert(filename_column_position, ::File.basename(filename))
104
+ end
105
+ end
106
+
107
+ yield row
87
108
  end
88
109
  end
89
110
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # This stores the current version of the NdrImport gem
3
3
  module NdrImport
4
- VERSION = '11.6.0'
4
+ VERSION = '11.7.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndr_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.6.0
4
+ version: 11.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NCRS Development Team