csv-probe 0.1.3 → 0.1.4

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: 4ea99229e9677a6c02d4197055be87cf2d7f052d1290cffad61a0cfb93c40175
4
- data.tar.gz: 4fbfbb4f010b5582a18671dd64a31bc8802fd831fb3dd3c4a5c447f9b2fd97d8
3
+ metadata.gz: 2425404adecef9f68fced84863e0acb087f3358935032c3849cab690948e74dc
4
+ data.tar.gz: 0bf460f9f27439cdcba3150c2f53991ab07512e6e1ffb5195315fdad5689c549
5
5
  SHA512:
6
- metadata.gz: 50b07ec40e594dfcf0e081ba5fbb8f625a993e7f7aadd48c4027346e1589ec5e61767ff14d8950c078d934ad1f3ecc8818d7a6be4721a73210cb41fdf63a15ba
7
- data.tar.gz: 3bf6d4365cb06bde99db33d52dbfea06ea202344dcab334723a39d20ce27eba91a53d49464d0af3132b83302d2d9942bd09cdcd3943661b9c702788f7e04f523
6
+ metadata.gz: 721e33de3a86d0513dcaab1d0d102454fbcf48492dd6d551ec1f5623de6c0b7ba74189ea7d6ae8825eb34674b2679f251e50c08e87fabf1ae18a993cdc72eaff
7
+ data.tar.gz: 042b6b18255ddbb787c7318febbc31147e4e593cbedf67047bc25c962491a9a46b3e664841a18ea3b8bfb25ef4025455391a4c7571dbf1a37072bb75c64967f8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2022-01-05
4
+ - Fix `nil` handling for list + set column checks when the list or set is something like this:
5
+ - `a,|b|,b` leading and trailing empty items or
6
+ - `a,,b` the whole list/set string is nil
7
+
3
8
  ## [0.1.3] - 2022-01-04
4
9
  - Add better `nil` handling to list + set column checks. `nil` resp. `""` does no longer implicitly pass ColumnIsListWithDomain and ColumnIsSetWithDomain checks. `nil` or `""` has to be in the expected items in order to pass the check now.
5
10
 
@@ -193,13 +193,15 @@ module Probe
193
193
  @ok_condition_fn = lambda { |val, _cfg|
194
194
  expected_items_arr.map!(&:to_s) # turn nil -> ""
195
195
 
196
- items = val.split(separator)
197
- return true if items.empty? && expected_items_arr.include?("") # empty str allowed
196
+ items = val.to_s.split(separator, -1)
197
+ return true if items.empty? && expected_items_arr.include?(nil.to_s) # empty str allowed
198
+
199
+ return false if items.empty?
198
200
 
199
201
  return items.all? { |e| expected_items_arr.include?(e) }
200
202
  }
201
203
  @fail_msg = lambda { |row, _opts|
202
- items = row.fetch(@varname).split(separator)
204
+ items = row.fetch(@varname).to_s.split(separator, -1)
203
205
  diff_items = items - expected_items_arr
204
206
  "expected that tokenized items of value #{items.inspect} are a subset of "\
205
207
  "#{expected_items_arr.inspect}, but items #{diff_items.inspect} are not"
@@ -212,12 +214,14 @@ module Probe
212
214
  def initialize(varname, separator, _placeholder = nil) # rubocop:disable Metrics/MethodLength
213
215
  super(varname, nil, nil)
214
216
  @ok_condition_fn = lambda { |val, _cfg|
215
- items = val.split(separator)
217
+ return true if val.to_s == ''
218
+
219
+ items = val.to_s.split(separator, -1)
216
220
  all_uniq = (items.size == items.uniq.size)
217
221
  return all_uniq
218
222
  }
219
223
  @fail_msg = lambda { |row, _opts|
220
- items = row.fetch(@varname).split(separator)
224
+ items = row.fetch(@varname).to_s.split(separator, -1)
221
225
  non_uniq_items = items.detect { |e| items.count(e) > 1 }
222
226
  "expected that items of tokenized value #{items.inspect} are uniqe, but items #{non_uniq_items.inspect} are not"
223
227
  }
@@ -232,14 +236,16 @@ module Probe
232
236
  @ok_condition_fn = lambda { |val, _cfg|
233
237
  expected_items_arr.map!(&:to_s) # turn nil -> ""
234
238
 
235
- items = val.split(separator)
236
- return true if items.empty? && expected_items_arr.include?("") # empty str allowed
239
+ items = val.to_s.split(separator, -1)
240
+ return true if items.empty? && expected_items_arr.include?(nil.to_s) # empty str allowed
241
+
242
+ return false if items.empty?
237
243
 
238
244
  all_valid = items.all? { |i| expected_items_arr.include?(i) }
239
245
  return all_valid
240
246
  }
241
247
  @fail_msg = lambda { |row, _opts|
242
- items = row.fetch(@varname).split(separator)
248
+ items = row.fetch(@varname).to_s.split(separator, -1)
243
249
  "expected that items of tokenized value #{items.inspect} are a subset of #{expected_items_arr.inspect}"
244
250
  }
245
251
  # @fail_msg = lambda {|row, opts|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Probe
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  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.3
4
+ version: 0.1.4
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-04 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv