csv-probe 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/csv/probe/checks.rb +11 -0
- data/lib/csv/probe/version.rb +1 -1
- data/lib/csv/probe.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 439f94912c7166ec674485a9ddcb15e77f18e84d65ef48548989937a1d98e900
|
4
|
+
data.tar.gz: 74b2ac04bb85f86aa9f5c2237d183bf8822c6cc2144abef1e5be82e15438ec75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9adae1d9582a6a765f17bd8382ab54bbf315de9b6355f621d703ef629fc22811699158b9f7cc8e129711d29b3e0b6b96b689b0fc893c8364d1f29ec26ba41c42
|
7
|
+
data.tar.gz: 5100684aa7f2db60a60b84b60c3fa86198c43e21cc4142010f4900cabdf3e8d504f31ffa682a1fc4a079f2e3fa19871b0b8eeb20612950dc828536cd3d5ff512
|
data/CHANGELOG.md
CHANGED
data/lib/csv/probe/checks.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module Probe
|
4
4
|
class Error < StandardError; end
|
5
5
|
|
6
|
+
class ChecksInvalidTypeError < Error; end
|
7
|
+
|
6
8
|
class LintingError < Error; end
|
7
9
|
|
8
10
|
# Linting error in CSV::Row, if the rule applies to multiple columns of a row
|
@@ -186,6 +188,15 @@ module Probe
|
|
186
188
|
end
|
187
189
|
end
|
188
190
|
|
191
|
+
# Check if a column value is a date with a given format
|
192
|
+
class ColumnNotMatchesRegEx < ColumnMeetsCondition
|
193
|
+
def initialize(varname, expected_regex_pattern, _placeholder = nil)
|
194
|
+
super(varname, nil, nil)
|
195
|
+
@ok_condition_fn = ->(val, _cfg) { val.to_s !~ expected_regex_pattern }
|
196
|
+
@fail_msg = "expected to NOT match regex pattern #{expected_regex_pattern.inspect}"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
189
200
|
# rubocop:disable Metrics/AbcSize
|
190
201
|
# Check if a tokenized column value is a list of given values
|
191
202
|
class ColumnIsListWithDomain < ColumnMeetsCondition
|
data/lib/csv/probe/version.rb
CHANGED
data/lib/csv/probe.rb
CHANGED
@@ -28,6 +28,12 @@ module Probe
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.lint_row(csv_row, checks, opts = {})
|
31
|
+
unless checks.is_a? Array
|
32
|
+
raise ChecksInvalidTypeError, "checks are expected to be of type error, but are of type '#{checks.class}'"
|
33
|
+
end
|
34
|
+
|
35
|
+
return if checks.empty? # nothing to do if there are no checks
|
36
|
+
|
31
37
|
unless csv_row.is_a? CSV::Row
|
32
38
|
raise Error "lint_row(csv_row,...), csv_row is not of type CSV::Row, but of type '#{csv_row.class}'"
|
33
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv-probe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- homebase.dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: csv
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.1.6
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Allows validation of CSV::Table or CSV::Rows via custom rules
|