patchwork_csv_utils 0.1.16-aarch64-linux → 0.1.17-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 303f1fba53339dc1c5a34072eec44649460de79d8d594f3a59a9a656d302d63c
4
- data.tar.gz: 4c41792380ad3da07de17b366b09b934063dfa660e7b6b3b165b39e53f80dcb3
3
+ metadata.gz: 87156b5f075414e4823da5e1d57b2f437bdbb399b16fa538a819f70d648635af
4
+ data.tar.gz: 3efad2ddb360387d71f9e70e03efa7e35f9cb898bf9f6f2bff7eee4b479f0249
5
5
  SHA512:
6
- metadata.gz: 0d9938712374b5409eafcd42eebcaa21b0fe220f4198aab91e3da44cf3052c4a5baf9c90e34b307c542de4667a1edeb7f1d64025061fe27d5a693b85900f1b67
7
- data.tar.gz: d11877e4bc89460b2090f4f1853ef3b82403ff744b3b55ad1ec7a4aea961b42ed38d4f121f36f4ed647f7af0cc9e88ba338b969f8d71146939a706b9bbbcbfb1
6
+ metadata.gz: b960428a14467b037ef97587b872569e8cd5186a9fdbfac7d54eb66b42ea5dad7b6775b72f6eb47191ae3e923fce6fe084dac8c082fed1c0c7c8cc55713eb6ee
7
+ data.tar.gz: a0bb2bfd6855a7d331de2b3526e011f95c2393413aefc7cddcb60067e7306d8cac3424e317f2fba700987f98e4d0c5b4d31ba1559f9a7e7837c2daaaf26254c0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patchwork_csv_utils (0.1.16)
4
+ patchwork_csv_utils (0.1.17)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -4,7 +4,7 @@ use chrono::{NaiveDate, NaiveDateTime, NaiveTime, Utc};
4
4
  use csv::{Reader, StringRecord, Writer};
5
5
  use magnus::{Error, RArray, Ruby};
6
6
 
7
- use crate::utils::{FileExtension, magnus_err, missing_header, to_datetime_error, check_mandatory_headers, create_header_map, missing_value, headers_as_byte_record, index_of_header_in_mandatory_list, validate_trust_name};
7
+ use crate::utils::{FileExtension, magnus_err, missing_header, to_datetime_error, check_mandatory_headers, create_header_map, missing_value, headers_as_byte_record, index_of_header_in_mandatory_list};
8
8
 
9
9
  pub fn transform_csv(ruby: &Ruby, csv_path: String,
10
10
  target_path: String, exclusions: RArray,
@@ -87,6 +87,16 @@ pub fn transform_csv(ruby: &Ruby, csv_path: String,
87
87
  Ok(())
88
88
  }
89
89
 
90
+
91
+ fn validate_trust_name(ruby: &Ruby, expected_trust_name: &String, trust_name: &usize, ri: usize, i: usize, s: &String) -> magnus::error::Result<()> {
92
+ if i == *trust_name {
93
+ if s != &expected_trust_name.clone() {
94
+ return Err(magnus::Error::new(ruby.exception_standard_error(), format!("Trust actual name: '{}' is not as expected: '{}'", s, expected_trust_name)));
95
+ }
96
+ }
97
+ Ok(())
98
+ }
99
+
90
100
  fn get_mandatory_records(ruby: &Ruby, csv: &mut Reader<File>, csv_header_list: &Vec<String>, mandatory_headers_list: &Vec<String>) -> magnus::error::Result<Vec<StringRecord>> {
91
101
  let inverse_header_map: HashMap<usize, String> = csv_header_list.iter().enumerate().map(|(i, h)| (i, h.to_string())).collect();
92
102
 
@@ -9,15 +9,6 @@ pub mod csv;
9
9
  pub mod dedup;
10
10
  pub mod xls;
11
11
 
12
- fn validate_trust_name(ruby: &Ruby, expected_trust_name: &String, trust_name: &usize, ri: usize, i: usize, s: &String) -> magnus::error::Result<()> {
13
- if ri > 0 && i == *trust_name {
14
- if s != &expected_trust_name.clone() {
15
- return Err(magnus::Error::new(ruby.exception_standard_error(), format!("Trust actual name: '{}' is not as expected: '{}'", s, expected_trust_name)));
16
- }
17
- }
18
- Ok(())
19
- }
20
-
21
12
  fn missing_header(ruby: &Ruby, header: &str) -> magnus::Error {
22
13
  magnus::Error::new(ruby.exception_standard_error(), format!("Missing '{}' header", header))
23
14
  }
@@ -6,7 +6,7 @@ use calamine::{Data, open_workbook, Range, Reader, Xls};
6
6
  use chrono::{NaiveDateTime, Utc};
7
7
  use magnus::{RArray, Ruby};
8
8
 
9
- use crate::utils::{FileExtension, magnus_err, missing_header, to_datetime_error, check_mandatory_headers, missing_value, index_of_header_in_mandatory_list, validate_trust_name};
9
+ use crate::utils::{FileExtension, magnus_err, missing_header, to_datetime_error, check_mandatory_headers, missing_value, index_of_header_in_mandatory_list};
10
10
 
11
11
  pub fn to_csv(ruby: &Ruby, xls_path: String,
12
12
  target_path: String,
@@ -69,6 +69,7 @@ fn write_csv<W: Write>(ruby: &Ruby, dest: &mut W, range: &Range<Data>,
69
69
  if date_value_is_not_present(&date, &r) {
70
70
  return Err(magnus::Error::new(ruby.exception_standard_error(), format!("Date value is not present in row: {}", ri)));
71
71
  }
72
+ validate_trust_name(ruby, &expected_trust_name, trust_name, ri, &r)?;
72
73
 
73
74
  for (i, c) in mandatory_headers.iter().enumerate() {
74
75
  let column_index = header_map.get(c).ok_or(missing_header(ruby, c))?;
@@ -77,7 +78,6 @@ fn write_csv<W: Write>(ruby: &Ruby, dest: &mut W, range: &Range<Data>,
77
78
  match *c {
78
79
  Data::Empty => Ok(()),
79
80
  Data::String(ref s) | Data::DateTimeIso(ref s) | Data::DurationIso(ref s) => {
80
- validate_trust_name(ruby, &expected_trust_name, trust_name, ri, i, s)?;
81
81
  handle_commas(dest, s)
82
82
  }
83
83
  Data::Float(ref f) => write!(dest, "{}", f),
@@ -103,6 +103,16 @@ fn write_csv<W: Write>(ruby: &Ruby, dest: &mut W, range: &Range<Data>,
103
103
  Ok(())
104
104
  }
105
105
 
106
+ fn validate_trust_name(ruby: &Ruby, expected_trust_name: &String, trust_name: &usize, ri: usize, r: &Vec<&Data>) -> magnus::error::Result<()> {
107
+ if ri > 0 {
108
+ let s = r[*trust_name].to_string();
109
+ if s != expected_trust_name.clone() {
110
+ return Err(magnus::Error::new(ruby.exception_standard_error(), format!("Trust actual name: '{}' is not as expected: '{}'", s, expected_trust_name)));
111
+ }
112
+ }
113
+ Ok(())
114
+ }
115
+
106
116
  fn get_mandatory_records<'a>(ruby: &Ruby, range: &'a Range<Data>, csv_header_list: &Vec<String>, mandatory_headers_list: &Vec<String>) -> magnus::error::Result<Vec<Vec<&'a Data>>> {
107
117
  let inverse_header_map: HashMap<usize, String> = csv_header_list.iter().enumerate().map(|(i, h)| (i, h.to_string())).collect();
108
118
 
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.16'
4
+ VERSION = '0.1.17'
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.16
4
+ version: 0.1.17
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - kingsley.hendrickse
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-25 00:00:00.000000000 Z
11
+ date: 2024-11-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Deduplication of CSV files and XLS to CSV conversion.
14
14
  email: