strong_csv 0.8.0 → 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: 558e352db4ff9f2f719b9bb9f6217c007ff679133e2b02449858af679289281d
4
- data.tar.gz: ff9881d662a6301fbdfe30bab16f02e440fc6939d0b4e89482216d1fe8902450
3
+ metadata.gz: 87d85fbdffebb9ee14657c9fe09099df0dba44c196c8da8de01518e157f4d4ca
4
+ data.tar.gz: 74575a412ddababb78fbb053b9fbd0ace06cc83ee27a5ac85be90e1eb91b4e08
5
5
  SHA512:
6
- metadata.gz: 2dfc2c45143b4e4b435cb72627ce4a82311a5506e7fbe35449179684b2fb8ac048d509a23e1f8e08442c35d4188cdc5abc3cdd285165b1b8f1e69763b1993cf6
7
- data.tar.gz: df17d984643c7830729a49c1284b60dafab1ddc14445d414d631bc87a135943cc9988cfb200f934c744d0b38cf8872a9d597ad422766cc89d08840c140f5dec4
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.0"
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.0
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-20 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.
@@ -42,7 +42,6 @@ licenses:
42
42
  metadata:
43
43
  homepage_uri: https://github.com/yykamei/strong_csv
44
44
  source_code_uri: https://github.com/yykamei/strong_csv
45
- changelog_uri: https://github.com/yykamei/strong_csv/blob/main/CHANGELOG.md
46
45
  rubygems_mfa_required: 'true'
47
46
  post_install_message:
48
47
  rdoc_options: []
@@ -59,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
58
  - !ruby/object:Gem::Version
60
59
  version: '0'
61
60
  requirements: []
62
- rubygems_version: 3.4.6
61
+ rubygems_version: 3.4.10
63
62
  signing_key:
64
63
  specification_version: 4
65
64
  summary: Type check CSV objects