csv-probe 0.1.2 → 0.1.3

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: 441ebf45d96b8a4dd857fb07accc96117d38557e89697bfb7bda9f3552dfab0b
4
- data.tar.gz: 629343b0c775afa3777c1087862b1ed1116a6c7a71c074fae386a4091d4fa0fa
3
+ metadata.gz: 4ea99229e9677a6c02d4197055be87cf2d7f052d1290cffad61a0cfb93c40175
4
+ data.tar.gz: 4fbfbb4f010b5582a18671dd64a31bc8802fd831fb3dd3c4a5c447f9b2fd97d8
5
5
  SHA512:
6
- metadata.gz: d38d085bb5cdf931e0b28bb392e74fda65cdd0fb5e6a48237fce7416b5c5defc67e1aa311dc3c301fff9a2c86f75fc6ce2be42c5a1ee971c1684086565175f2d
7
- data.tar.gz: d50453598bbbd185db46d2d01ab62d72487540d30b24d60cdbcd99bf29a2ba7a44f13e36661837c6cc12dd12d1d1576f88dfe9f65561733b05adf016b233078d
6
+ metadata.gz: 50b07ec40e594dfcf0e081ba5fbb8f625a993e7f7aadd48c4027346e1589ec5e61767ff14d8950c078d934ad1f3ecc8818d7a6be4721a73210cb41fdf63a15ba
7
+ data.tar.gz: 3bf6d4365cb06bde99db33d52dbfea06ea202344dcab334723a39d20ce27eba91a53d49464d0af3132b83302d2d9942bd09cdcd3943661b9c702788f7e04f523
data/CHANGELOG.md CHANGED
@@ -1,11 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2022-01-04
4
+ - 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
+
3
6
  ## [0.1.2] - 2022-01-03
4
- - Fix readme
7
+ - Fix README.md
5
8
 
6
9
  ## [0.1.1] - 2022-01-02
7
10
  - Fix rubocop warnings
8
- - Improve readme
11
+ - Improve README.md
9
12
 
10
13
  ## [0.1.0] - 2022-01-02
11
14
 
data/README.md CHANGED
@@ -24,6 +24,9 @@ Or install it yourself as:
24
24
  Example how to use Probe
25
25
 
26
26
  ```ruby
27
+ # load csv-probe gem
28
+ require 'csv/probe'
29
+
27
30
  # load CSV into CSV::Table
28
31
  csv_table = CSV.parse(<<~ROWS, headers: true)
29
32
  col1,col2,col3,col4,col5,col6,col7
@@ -191,7 +191,11 @@ module Probe
191
191
  def initialize(varname, expected_items_arr, separator, _placeholder = nil) # rubocop:disable Metrics/MethodLength
192
192
  super(varname, nil, nil)
193
193
  @ok_condition_fn = lambda { |val, _cfg|
194
+ expected_items_arr.map!(&:to_s) # turn nil -> ""
195
+
194
196
  items = val.split(separator)
197
+ return true if items.empty? && expected_items_arr.include?("") # empty str allowed
198
+
195
199
  return items.all? { |e| expected_items_arr.include?(e) }
196
200
  }
197
201
  @fail_msg = lambda { |row, _opts|
@@ -208,8 +212,6 @@ module Probe
208
212
  def initialize(varname, separator, _placeholder = nil) # rubocop:disable Metrics/MethodLength
209
213
  super(varname, nil, nil)
210
214
  @ok_condition_fn = lambda { |val, _cfg|
211
- return true if val.to_s == ""
212
-
213
215
  items = val.split(separator)
214
216
  all_uniq = (items.size == items.uniq.size)
215
217
  return all_uniq
@@ -228,9 +230,11 @@ module Probe
228
230
  super(varname, nil, nil)
229
231
  @pre_checks << ColumnIsSet.new(varname, separator)
230
232
  @ok_condition_fn = lambda { |val, _cfg|
231
- return true if val.to_s == ""
233
+ expected_items_arr.map!(&:to_s) # turn nil -> ""
232
234
 
233
235
  items = val.split(separator)
236
+ return true if items.empty? && expected_items_arr.include?("") # empty str allowed
237
+
234
238
  all_valid = items.all? { |i| expected_items_arr.include?(i) }
235
239
  return all_valid
236
240
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Probe
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/csv/probe.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "csv"
3
+ require "csv" # TODO: should i require it here?
4
4
  require "terminal-table"
5
5
  require_relative "probe/version"
6
6
  require_relative "probe/checks"
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.2
4
+ version: 0.1.3
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-02 00:00:00.000000000 Z
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv