csv-probe 0.1.4 → 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: 2425404adecef9f68fced84863e0acb087f3358935032c3849cab690948e74dc
4
- data.tar.gz: 0bf460f9f27439cdcba3150c2f53991ab07512e6e1ffb5195315fdad5689c549
3
+ metadata.gz: 439f94912c7166ec674485a9ddcb15e77f18e84d65ef48548989937a1d98e900
4
+ data.tar.gz: 74b2ac04bb85f86aa9f5c2237d183bf8822c6cc2144abef1e5be82e15438ec75
5
5
  SHA512:
6
- metadata.gz: 721e33de3a86d0513dcaab1d0d102454fbcf48492dd6d551ec1f5623de6c0b7ba74189ea7d6ae8825eb34674b2679f251e50c08e87fabf1ae18a993cdc72eaff
7
- data.tar.gz: 042b6b18255ddbb787c7318febbc31147e4e593cbedf67047bc25c962491a9a46b3e664841a18ea3b8bfb25ef4025455391a4c7571dbf1a37072bb75c64967f8
6
+ metadata.gz: 9adae1d9582a6a765f17bd8382ab54bbf315de9b6355f621d703ef629fc22811699158b9f7cc8e129711d29b3e0b6b96b689b0fc893c8364d1f29ec26ba41c42
7
+ data.tar.gz: 5100684aa7f2db60a60b84b60c3fa86198c43e21cc4142010f4900cabdf3e8d504f31ffa682a1fc4a079f2e3fa19871b0b8eeb20612950dc828536cd3d5ff512
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
7
+ ## [0.1.5] - 2022-01-05
8
+ - Fix rubocop warnings
9
+
3
10
  ## [0.1.4] - 2022-01-05
4
11
  - Fix `nil` handling for list + set column checks when the list or set is something like this:
5
12
  - `a,|b|,b` leading and trailing empty items or
@@ -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,16 @@ 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
+
200
+ # rubocop:disable Metrics/AbcSize
189
201
  # Check if a tokenized column value is a list of given values
190
202
  class ColumnIsListWithDomain < ColumnMeetsCondition
191
203
  def initialize(varname, expected_items_arr, separator, _placeholder = nil) # rubocop:disable Metrics/MethodLength
@@ -214,7 +226,7 @@ module Probe
214
226
  def initialize(varname, separator, _placeholder = nil) # rubocop:disable Metrics/MethodLength
215
227
  super(varname, nil, nil)
216
228
  @ok_condition_fn = lambda { |val, _cfg|
217
- return true if val.to_s == ''
229
+ return true if val.to_s == ""
218
230
 
219
231
  items = val.to_s.split(separator, -1)
220
232
  all_uniq = (items.size == items.uniq.size)
@@ -254,6 +266,7 @@ module Probe
254
266
  # are uniqe and a subset of #{expected_items_arr.inspect}" }
255
267
  end
256
268
  end
269
+ # rubocop:enable Metrics/AbcSize
257
270
 
258
271
  # TODO: nice to have
259
272
  # * if_second_not_empty_then_first_yes_check(varname1, varname2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Probe
4
- VERSION = "0.1.4"
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.4
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