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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 945175b169f28d0b77504d23cf6020d5216e66f74e8e5a8b04ef0279f681fd8c
4
- data.tar.gz: a91cb9d894402b70ebfb72a342f4166a94bda0b3c6f1ba361920d0caa6b3c0c9
3
+ metadata.gz: 439f94912c7166ec674485a9ddcb15e77f18e84d65ef48548989937a1d98e900
4
+ data.tar.gz: 74b2ac04bb85f86aa9f5c2237d183bf8822c6cc2144abef1e5be82e15438ec75
5
5
  SHA512:
6
- metadata.gz: 7d09e366f9e7b4692dbfb1f8389667952f5e3a913901600d77d9954a9b5685650d81b6b9bba701cfa2925c47cefb0aca2e4b4bd5d48a3547b7cd2c775e512e01
7
- data.tar.gz: a076a71e6679f69848b7c30117a100986e3857eb41a3ad2bed50c0a6b320add76caf6668ae8790dce9804c82e2f7dcc5b0e0e8675972c8f81a594bc163501f73
6
+ metadata.gz: 9adae1d9582a6a765f17bd8382ab54bbf315de9b6355f621d703ef629fc22811699158b9f7cc8e129711d29b3e0b6b96b689b0fc893c8364d1f29ec26ba41c42
7
+ data.tar.gz: 5100684aa7f2db60a60b84b60c3fa86198c43e21cc4142010f4900cabdf3e8d504f31ffa682a1fc4a079f2e3fa19871b0b8eeb20612950dc828536cd3d5ff512
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.6] - 2022-11-11
4
+ - Add ColumnNotMatchesRegEx class
5
+ - Raise InvalidTypeError when passed checks argument is not of type array
6
+
3
7
  ## [0.1.5] - 2022-01-05
4
8
  - Fix rubocop warnings
5
9
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Probe
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
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.5
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-01-05 00:00:00.000000000 Z
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.2.29
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