strong_csv 0.8.1 → 0.8.2

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: 0bf72430d106db5258d3dc4a32d4c2c1a5bfa0ab0fd74b0e958efe1bf073e942
4
- data.tar.gz: 51d96be97ee05967b85b4e09a57822678cdf755121aa01fc5e185dc9bdcc976a
3
+ metadata.gz: 87d85fbdffebb9ee14657c9fe09099df0dba44c196c8da8de01518e157f4d4ca
4
+ data.tar.gz: 74575a412ddababb78fbb053b9fbd0ace06cc83ee27a5ac85be90e1eb91b4e08
5
5
  SHA512:
6
- metadata.gz: 131ac972c42725f4049fde7f9c11d5226b245b11a650456079e49d4bb95a379f0b44657257e5d0738547fb2adcf16ff63c6e78b0a8f773491124936de9f0490e
7
- data.tar.gz: bb9f719790fe36f6991a93fa18619723c33549c7fd9a7c597926bc0793ad5cdfc572ae886070681d7af08b7a6817e4067681ceeee081f262cd20e8a00b427a45
6
+ metadata.gz: 0be982e1c85e044466ffba782e74e037e20365b080450f078223be1285b787570038258a705bb8e21caaf7c45a1f3e57b041f7a0ffb62e16d97237b0296698e3
7
+ data.tar.gz: e9ebbeae9e5993c10b655f2626a17bcdbb6e6abbb9ecdd66b9e8e60d24fedf63a7d2e59552930b2c7897b8795a590e55409eb8fd836353184955d419ba37acb9
@@ -23,7 +23,7 @@ class StrongCSV
23
23
  # @param type [StrongCSV::Type::Base]
24
24
  # @param types [Array<StrongCSV::Type::Base>]
25
25
  def let(name, type, *types, error_message: nil, &block)
26
- type = types.empty? ? type : Types::Union.new(type, *types)
26
+ type = Types::Union.new(type, *types) unless types.empty?
27
27
  case name
28
28
  when ::Integer
29
29
  @types << TypeWrapper.new(name: name, type: type, block: block, error_message: error_message)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class StrongCSV
4
- VERSION = "0.8.1"
4
+ VERSION = "0.8.2"
5
5
  end
data/lib/strong_csv.rb CHANGED
@@ -21,6 +21,21 @@ require_relative "strong_csv/let"
21
21
  require_relative "strong_csv/row"
22
22
 
23
23
  # StrongCSV is a library for parsing CSV contents with type checking.
24
+ #
25
+ # @example
26
+ # strong_csv = StrongCSV.new do
27
+ # let :name, string(within: 1..255)
28
+ # let :score, integer
29
+ # end
30
+ #
31
+ # result = strong_csv.parse(<<~CSV)
32
+ # name,score
33
+ # JJ,X
34
+ # Tomo,23
35
+ # Haru,9
36
+ # CSV
37
+ # result.map(&:valid?) # => [false, true, true]
38
+ #
24
39
  class StrongCSV
25
40
  class Error < StandardError; end
26
41
 
@@ -47,7 +62,7 @@ class StrongCSV
47
62
  yield Row.new(row: row, types: @let.types, lineno: csv.lineno)
48
63
  end
49
64
  else
50
- csv.each.map { |row| Row.new(row: row, types: @let.types, lineno: csv.lineno) }
65
+ csv.map { |row| Row.new(row: row, types: @let.types, lineno: csv.lineno) }
51
66
  end
52
67
  end
53
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yutaka Kamei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
11
+ date: 2023-09-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: strong_csv is a type checker for a CSV file. It lets developers declare
14
14
  types for each column to ensure all cells are satisfied with desired types.
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubygems_version: 3.4.6
61
+ rubygems_version: 3.4.10
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Type check CSV objects