patchwork_csv_utils 0.1.21-x86_64-linux → 0.1.22-x86_64-linux

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: '05919ff686082e5b6623d95609a88ce8becf427d84ac5fd5b75f25fb805a886a'
4
- data.tar.gz: 18a5291b26af0ab431f1ff0bcd7954459292caaaefee3c7c2eb71de89921aa5a
3
+ metadata.gz: 5b284ba3c70cec13c91ba655fb13145182d8da5bcc80c018a388eb630bc27865
4
+ data.tar.gz: 4bc87184786c705c5fe022e169bcd9f17243314f96a3c4a5c8132ca45a11330d
5
5
  SHA512:
6
- metadata.gz: c2efa877128736c0a0e889a69b043f0736659ccb1adb7b37c883c05d636d8edeed74419437cc32e10c8ff625520d32f8c795a356bce93f61234b3885ca9011f9
7
- data.tar.gz: 4562c3b6c7f4ed1abecc39e88465bcdff1a5689a4995ce6b42dac8623c07d7fa47736936e2f7df818281b8800e4764b40a93f6c53a7c57e607a92cdae08476d0
6
+ metadata.gz: 75133438e59bf485be49345ca0f9e6cb3ec3c60a85036069b2a6e0757bb9d326cc989f4d7ed822993ad1b50bcbea4e19f7e32f86dc4e995ff0964e94e3c8d092
7
+ data.tar.gz: c91c751ac4af03e02628fff0616c7da7d64d57bf57bec384a5799869b7f5fda1edb4550b80c7761f56227b83f6349eddf9b2ae0f8f4a6b80b75046a4a5c3645b
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.0.7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patchwork_csv_utils (0.1.21)
4
+ patchwork_csv_utils (0.1.22)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -56,6 +56,7 @@ GEM
56
56
  PLATFORMS
57
57
  arm64-darwin-22
58
58
  arm64-darwin-23
59
+ arm64-darwin-24
59
60
  x86_64-linux
60
61
 
61
62
  DEPENDENCIES
@@ -6,8 +6,10 @@ use std::fs::File;
6
6
 
7
7
  use crate::utils::{check_mandatory_headers, create_header_map, headers_as_byte_record, index_of_header_in_mandatory_list, magnus_err, missing_header, missing_value, to_datetime_error, FileExtension};
8
8
 
9
- pub fn transform_csv(ruby: &Ruby, csv_path: String,
10
- target_path: String, exclusions: RArray,
9
+ pub fn transform_csv(ruby: &Ruby,
10
+ csv_path: String,
11
+ target_path: String,
12
+ exclusions: RArray,
11
13
  mandatory_headers: RArray,
12
14
  status_exclusions: RArray,
13
15
  expected_trust_name: String,
@@ -48,7 +50,7 @@ pub fn transform_csv(ruby: &Ruby, csv_path: String,
48
50
 
49
51
  for (ri, record) in mandatory_records.iter().enumerate() {
50
52
 
51
- if skip_excluded_rows(request_id, &record, &exclusions) { continue; }
53
+ if skip_excluded_rows(request_id, &status, &record, &exclusions) { continue; }
52
54
  if skip_excluded_status_rows(&status, &record, &status_exclusions) { continue; }
53
55
  if has_empty_row_skip(&record) { continue; }
54
56
  if has_empty_first_col_skip_row(&record) { continue; }
@@ -140,7 +142,15 @@ fn get_column_name(inverse_header_map: &HashMap<usize, String>, i: &usize) -> St
140
142
  column_name.to_string()
141
143
  }
142
144
 
143
- fn skip_excluded_rows(request_id: &usize, r: &StringRecord, exclusions: &Vec<String>) -> bool {
145
+ fn skip_excluded_rows(request_id: &usize, status: &Option<&usize>, r: &StringRecord, exclusions: &Vec<String>) -> bool {
146
+ if let Some(status_index) = status {
147
+ if let Some(status) = r.get(**status_index) {
148
+ if status.eq("Recalled") {
149
+ return false
150
+ }
151
+ }
152
+ }
153
+
144
154
  let value = r.get(*request_id).unwrap_or_default();
145
155
  exclusions.contains(&value.to_string())
146
156
  }
@@ -2,7 +2,7 @@ use std::collections::HashMap;
2
2
  use std::fs::File;
3
3
  use std::io::{BufWriter, Write};
4
4
 
5
- use calamine::{open_workbook_auto, Data, Range, Reader};
5
+ use calamine::{open_workbook_auto, Data, DataType, Range, Reader};
6
6
  use chrono::{NaiveDateTime, Timelike, Utc};
7
7
  use magnus::{RArray, Ruby};
8
8
 
@@ -66,7 +66,7 @@ fn write_csv<W: Write>(ruby: &Ruby, dest: &mut W, range: &Range<Data>,
66
66
  for (ri, r) in mandatory_rows.into_iter().enumerate() {
67
67
  let mut date_value = Utc::now().naive_utc();
68
68
 
69
- if skip_excluded_rows(&request_id, &r, &exclusions) { continue; }
69
+ if skip_excluded_rows(&request_id, &status, &r, &exclusions) { continue; }
70
70
  if skip_excluded_status_rows(&status, &r, &status_exclusions) { continue; }
71
71
  if skip_empty_rows(&r) { continue; }
72
72
  if skip_rows_with_no_request_id(&request_id, &r) { continue; }
@@ -185,7 +185,17 @@ fn date_value_is_not_present(date: &usize, r: &Vec<&Data>) -> bool {
185
185
  r[*date] == &Data::Empty
186
186
  }
187
187
 
188
- fn skip_excluded_rows(request_id: &usize, r: &Vec<&Data>, exclusions: &Vec<String>) -> bool {
188
+ fn skip_excluded_rows(request_id: &usize, status: &Option<&usize>, r: &Vec<&Data>, exclusions: &Vec<String>) -> bool {
189
+ if let Some(status_index) = status {
190
+ if let Some(status) = r.get(**status_index) {
191
+ if let Some(status_str) = status.as_string() {
192
+ if status_str.eq("Recalled") {
193
+ return false
194
+ }
195
+ }
196
+ }
197
+ }
198
+
189
199
  let value = r[*request_id].to_string();
190
200
  exclusions.contains(&value.to_string())
191
201
  }
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CsvUtils
4
- VERSION = '0.1.21'
4
+ VERSION = '0.1.22'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patchwork_csv_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - kingsley.hendrickse
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-14 00:00:00.000000000 Z
11
+ date: 2025-07-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Deduplication of CSV files and XLS to CSV conversion.
14
14
  email:
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".rspec"
21
21
  - ".rubocop.yml"
22
+ - ".ruby-version"
22
23
  - Cargo.lock
23
24
  - Cargo.toml
24
25
  - Gemfile