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 +4 -4
- data/README.md +2 -0
- data/ext/osv/src/csv/parser.rs +2 -2
- data/ext/osv/src/reader.rs +5 -0
- data/lib/osv/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba77f8e6d2a8d19d969871594f1c2b18557125d3eee4b5c2759a0398d21da01
|
4
|
+
data.tar.gz: da35996064fd954c99e6241c045444ec5dc1dc52204db956291401d0c3dfe805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/ext/osv/src/csv/parser.rs
CHANGED
@@ -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", "")
|
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", "")
|
82
|
+
Some(CowStr(Cow::Owned(field.replace("\0", ""))))
|
83
83
|
}
|
84
84
|
else {
|
85
85
|
Some(CowStr(Cow::Owned(field.to_string())))
|
data/ext/osv/src/reader.rs
CHANGED
@@ -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