patchwork_csv_utils 0.1.16-arm64-darwin → 0.1.17-arm64-darwin

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: 8bc0fc6a96beb105819f545deea0461cecdd83b279ed83fa37034801cb3bcab7
4
- data.tar.gz: 619cd75e95bb9ae03bf583446f10aa35cd95e39cc8c38f9acdd480e90bcd82d7
3
+ metadata.gz: 5977699b20c42ee8e272bbec4d59cb5f8ee94becfbb0f89706a5175a38ddf3af
4
+ data.tar.gz: 445dac8eeccda255f28c2d6ddf055473f4f7388b8ac4180e8b1c9dfa549d66c5
5
5
  SHA512:
6
- metadata.gz: d6212b706fa1feaf0d5200c291977ef372fadf9c2c35038211082c58b4e531b6fb1e08d01efd741f087a9c80fdbaa7f1135409fdc28b99a08262b61b883527a4
7
- data.tar.gz: 69e2868e1e9bf8f57874457fafa6857b58cd9236a7677806fe716fb779bb6cd620e3497b75b9c5aef6006e5073b5115dfdfd5d04b61ec60aff9891ef1d07839c
6
+ metadata.gz: 3d9a437b3f2e3e6caf52db149d0995c48afd7c2ed39275d319472a3450de97d9591b0117b9fa4fef3114bcb5ca473705e8da3f131e6b94b693573b9a502e1159
7
+ data.tar.gz: a699982a4a5a2981d38558535da903b50be775c59b4600b467bb85d0d2318a275f321f981ce77e0f61e6fc8d2eb8705c88f400ce0c7e9da382c419ed78d6fc66
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: arm64-darwin
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: