patchwork_csv_utils 0.1.16-x86_64-linux → 0.1.17-x86_64-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: ccd0a5a1fac5fc48723b28f4b0922ee10468b2bcf26bb6da77a7abdcb9c3882f
4
- data.tar.gz: b9be825c7c520ef319c940814863f71e71c41d0ed2be062179e665110dfcb0d6
3
+ metadata.gz: f651263457993e883e97d83546cac1a67e20bc27803fb50ae696c7a8cbba01b5
4
+ data.tar.gz: f2c54d9821a1681f0c4f1558bae989430a10e05fd3e0aa9fb15b111f782faab6
5
5
  SHA512:
6
- metadata.gz: f2419b94893570ef960dd9be99ed2d530b3b8d201b05a8373dd8a5a2b679e6c9f078e26ebc6f8a43f649158e2984ed9c10dad5d8c7ebac80ffe6b927ca2250fc
7
- data.tar.gz: bb87188b17f9e95e3cdf7db797cf9ae067bb322151069f70b6caaa7c8749ec9c2ecdb068136c55c0a010a0f67b5de9990192b4ca94fd6ec5b8e0d73da71a2ed9
6
+ metadata.gz: 33405ba1d371558c4d86e2be3ad2d5607764cd7a20c0e5ae00c505392b44587a814d0f1907dcfa9f18cc1be335fa3dde27ac44f407a0b66fa800609432e5377c
7
+ data.tar.gz: 48d09709995deffa38a6381b43640075b390e6863023aeaf4f4a40b4d385bf02ec626c31b4d4c28fe8cd0b3432928fc8fda3657f70a509be13d75c535373de26
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: x86_64-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: