osv 0.3.19 → 0.3.21

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: 87b1080bdb84d6db09a077d9eacc6c4792cfe93851671e4ba0438fe27c3d3218
4
- data.tar.gz: f1dc704d251d906e9d6011c288c37844af8ccc976eb90611c629b7bc9cc9353e
3
+ metadata.gz: dba77f8e6d2a8d19d969871594f1c2b18557125d3eee4b5c2759a0398d21da01
4
+ data.tar.gz: da35996064fd954c99e6241c045444ec5dc1dc52204db956291401d0c3dfe805
5
5
  SHA512:
6
- metadata.gz: aa7a083aebc9f480528de32fea2890189857c2381811f1cd90a8115724c75640a6bd11424e186492ace41a5fed28ee74dd17172f983801b48b31b81a750e24e9
7
- data.tar.gz: 214c20e5011660e2250364ca79bd91a6c812053b401e9a1266abd500cf1e9e7c045f02054144f46190e45b459480aae70bbfab4d19ab246d1e1f5a8556f616a1
6
+ metadata.gz: 26398c526e829d7a6c3f943e175d10f8f626a42cec81da9bb65b4fc30dd29078629d29602f4fe3461fbb2cc86ca6d1b91f7f5f6ba2e7de362c2d44f5a79fcf5a
7
+ data.tar.gz: 39cd4dd78ed38559302c9735b3514648fbc668b415be65870b4deecdea8b6fb41dc7053d347ea5c8fe8004cc653b933ec201eed98582d12cbb26d84302396372
data/README.md CHANGED
@@ -88,6 +88,7 @@ OSV.for_each("data.csv",
88
88
  # Implicitly enables flexible mode if set.
89
89
  trim: :all, # Whether to trim whitespace. Options are :all, :headers, or :fields (default: nil)
90
90
  buffer_size: 1024, # Number of rows to buffer in memory (default: 1024)
91
+ ignore_null_bytes: false, # Boolean specifying if null bytes should be ignored (default: false)
91
92
  )
92
93
  ```
93
94
 
@@ -104,6 +105,7 @@ OSV.for_each("data.csv",
104
105
  - `flexible`: Boolean specifying if the parser should be flexible (default: false)
105
106
  - `flexible_default`: String specifying the default value for missing fields. Implicitly enables flexible mode if set. (default: `nil`)
106
107
  - `trim`: String specifying the trim mode ("all" or "headers" or "fields" or :all or :headers or :fields)
108
+ - `ignore_null_bytes`: Boolean specifying if null bytes should be ignored (default: false)
107
109
 
108
110
  When `has_headers` is false, hash keys will be generated as `"c0"`, `"c1"`, etc.
109
111
 
@@ -43,7 +43,7 @@ impl<'a, S: BuildHasher + Default> RecordParser<'a>
43
43
  } else if field.is_empty() {
44
44
  Some(CowStr(shared_empty.clone()))
45
45
  } else if ignore_null_bytes {
46
- Some(CowStr(Cow::Owned(field.replace("\0", "").to_string())))
46
+ Some(CowStr(Cow::Owned(field.replace("\0", ""))))
47
47
  }
48
48
  else {
49
49
  Some(CowStr(Cow::Owned(field.to_string())))
@@ -79,7 +79,7 @@ impl<'a> RecordParser<'a> for Vec<Option<CowStr<'a>>> {
79
79
  } else if field.is_empty() {
80
80
  Some(CowStr(shared_empty.clone()))
81
81
  } else if ignore_null_bytes {
82
- Some(CowStr(Cow::Owned(field.replace("\0", "").to_string())))
82
+ Some(CowStr(Cow::Owned(field.replace("\0", ""))))
83
83
  }
84
84
  else {
85
85
  Some(CowStr(Cow::Owned(field.to_string())))
@@ -36,6 +36,7 @@ struct EnumeratorArgs {
36
36
  flexible: bool,
37
37
  flexible_default: Option<String>,
38
38
  trim: Option<String>,
39
+ ignore_null_bytes: bool,
39
40
  }
40
41
 
41
42
  /// Parses a CSV file with the given configuration.
@@ -80,6 +81,7 @@ pub fn parse_csv(
80
81
  Trim::Fields => Some("fields".to_string()),
81
82
  _ => None,
82
83
  },
84
+ ignore_null_bytes,
83
85
  });
84
86
  }
85
87
 
@@ -146,6 +148,9 @@ fn create_enumerator(
146
148
  kwargs.aset(Symbol::new("flexible_default"), args.flexible_default)?;
147
149
  kwargs.aset(Symbol::new("trim"), args.trim.map(Symbol::new))?;
148
150
 
151
+ kwargs.aset(Symbol::new("ignore_null_bytes"), args.ignore_null_bytes)?;
152
+
153
+
149
154
  let enumerator = args
150
155
  .rb_self
151
156
  .enumeratorize("for_each", (args.to_read, KwArgs(kwargs)));
data/lib/osv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OSV
2
- VERSION = "0.3.19"
2
+ VERSION = "0.3.21"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.19
4
+ version: 0.3.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Jaremko