csv 3.1.9 → 3.2.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: 44985560f2528c6909f94ce869ec8ddb014ee66d89fe940fe6f4c872f8773e97
4
- data.tar.gz: 60297accbe6a82852d251f5e4990dfacc241d6ec1084a39eb7ce39ac04c059d6
3
+ metadata.gz: 915b3ed5a51bf4836f08f7bb06efc3b07bdc90e09209a5253092130e2cad2ab6
4
+ data.tar.gz: 6bce2e39329afcf200691b4b2f422b6a48d45da66368f5d5e136e0c761cd6217
5
5
  SHA512:
6
- metadata.gz: 7d51eae6f0e4eaccf382ffc52306ff9b9235259353c8514aafc3fd0116449ae342d9b5972e6ab236ddad542a9a286580f060080503fb18a2f81dfc97299cb8e8
7
- data.tar.gz: ef7d5e134f0ed59e4e0e466c5a6c4a6e45d51ff90a8e3bc22be1014041d29cb3a70c6ae7b482865426d5957962007875b734364b43742b2b7074548d3263bc76
6
+ metadata.gz: 5c1434c8e91c16de40d19d4d1200f193248e786720b67f2bbecf26a481859fe814b8cbaa02d22027668ff02588541266c8ff5d00b9fc1cfc2163b358b8e9ece9
7
+ data.tar.gz: 1978e933549049129f0ec99e80a10f2838b3c75a282103aa177d8421fe7589d428308e2786b29a961a4a7a5565ede77e3b1ef44ba8f4bc91b593a5a884ded7aa
data/NEWS.md CHANGED
@@ -1,5 +1,135 @@
1
1
  # News
2
2
 
3
+ ## 3.2.3 - 2022-04-09
4
+
5
+ ### Improvements
6
+
7
+ * Added contents summary to `CSV::Table#inspect`.
8
+ [GitHub#229][Patch by Eriko Sugiyama]
9
+ [GitHub#235][Patch by Sampat Badhe]
10
+
11
+ * Suppressed `$INPUT_RECORD_SEPARATOR` deprecation warning by
12
+ `Warning.warn`.
13
+ [GitHub#233][Reported by Jean byroot Boussier]
14
+
15
+ * Improved error message for liberal parsing with quoted values.
16
+ [GitHub#231][Patch by Nikolay Rys]
17
+
18
+ * Fixed typos in documentation.
19
+ [GitHub#236][Patch by Sampat Badhe]
20
+
21
+ * Added `:max_field_size` option and deprecated `:field_size_limit` option.
22
+ [GitHub#238][Reported by Dan Buettner]
23
+
24
+ * Added `:symbol_raw` to built-in header converters.
25
+ [GitHub#237][Reported by taki]
26
+ [GitHub#239][Patch by Eriko Sugiyama]
27
+
28
+ ### Fixes
29
+
30
+ * Fixed a bug that some texts may be dropped unexpectedly.
31
+ [Bug #18245][ruby-core:105587][Reported by Hassan Abdul Rehman]
32
+
33
+ * Fixed a bug that `:field_size_limit` doesn't work with not complex row.
34
+ [GitHub#238][Reported by Dan Buettner]
35
+
36
+ ### Thanks
37
+
38
+ * Hassan Abdul Rehman
39
+
40
+ * Eriko Sugiyama
41
+
42
+ * Jean byroot Boussier
43
+
44
+ * Nikolay Rys
45
+
46
+ * Sampat Badhe
47
+
48
+ * Dan Buettner
49
+
50
+ * taki
51
+
52
+ ## 3.2.2 - 2021-12-24
53
+
54
+ ### Improvements
55
+
56
+ * Added a validation for invalid option combination.
57
+ [GitHub#225][Patch by adamroyjones]
58
+
59
+ * Improved documentation for developers.
60
+ [GitHub#227][Patch by Eriko Sugiyama]
61
+
62
+ ### Fixes
63
+
64
+ * Fixed a bug that all of `ARGF` contents may not be consumed.
65
+ [GitHub#228][Reported by Rafael Navaza]
66
+
67
+ ### Thanks
68
+
69
+ * adamroyjones
70
+
71
+ * Eriko Sugiyama
72
+
73
+ * Rafael Navaza
74
+
75
+ ## 3.2.1 - 2021-10-23
76
+
77
+ ### Improvements
78
+
79
+ * doc: Fixed wrong class name.
80
+ [GitHub#217][Patch by Vince]
81
+
82
+ * Changed to always use `"\n"` for the default row separator on Ruby
83
+ 3.0 or later because `$INPUT_RECORD_SEPARATOR` was deprecated
84
+ since Ruby 3.0.
85
+
86
+ * Added support for Ractor.
87
+ [GitHub#218][Patch by rm155]
88
+
89
+ * Users who want to use the built-in converters in non-main
90
+ Ractors need to call `Ractor.make_shareable(CSV::Converters)`
91
+ and/or `Ractor.make_shareable(CSV::HeaderConverters)` before
92
+ creating non-main Ractors.
93
+
94
+ ### Thanks
95
+
96
+ * Vince
97
+
98
+ * Joakim Antman
99
+
100
+ * rm155
101
+
102
+ ## 3.2.0 - 2021-06-06
103
+
104
+ ### Improvements
105
+
106
+ * `CSV.open`: Added support for `:newline` option.
107
+ [GitHub#198][Patch by Nobuyoshi Nakada]
108
+
109
+ * `CSV::Table#each`: Added support for column mode with duplicated
110
+ headers.
111
+ [GitHub#206][Reported by Yaroslav Berezovskiy]
112
+
113
+ * `Object#CSV`: Added support for Ruby 3.0.
114
+
115
+ * `CSV::Row`: Added support for pattern matching.
116
+ [GitHub#207][Patch by Kevin Newton]
117
+
118
+ ### Fixes
119
+
120
+ * Fixed typos in documentation.
121
+ [GitHub#196][GitHub#205][Patch by Sampat Badhe]
122
+
123
+ ### Thanks
124
+
125
+ * Sampat Badhe
126
+
127
+ * Nobuyoshi Nakada
128
+
129
+ * Yaroslav Berezovskiy
130
+
131
+ * Kevin Newton
132
+
3
133
  ## 3.1.9 - 2020-11-23
4
134
 
5
135
  ### Fixes
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # CSV
2
2
 
3
- [![Build Status](https://travis-ci.org/ruby/csv.svg?branch=master)](https://travis-ci.org/ruby/csv)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/321fa39e510a0abd0369/test_coverage)](https://codeclimate.com/github/ruby/csv/test_coverage)
5
-
6
3
  This library provides a complete interface to CSV files and data. It offers tools to enable you to read and write to and from Strings or IO objects, as needed.
7
4
 
8
5
  ## Installation
@@ -33,12 +30,12 @@ end
33
30
 
34
31
  ## Documentation
35
32
 
36
- - {API}[CSV.html]: all classes, methods, and constants.
37
- - {Recipes}[doc/csv/recipes/recipes_rdoc.html]: specific code for specific tasks.
33
+ - [API](https://ruby-doc.org/stdlib/libdoc/csv/rdoc/CSV.html): all classes, methods, and constants.
34
+ - [Recipes](https://ruby-doc.org/core/doc/csv/recipes/recipes_rdoc.html): specific code for specific tasks.
38
35
 
39
36
  ## Development
40
37
 
41
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+ After checking out the repo, run `ruby run-test.rb` to check if your changes can pass the test.
42
39
 
43
40
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
41
 
@@ -19,7 +19,7 @@ Without +write_headers+:
19
19
 
20
20
  With +write_headers+":
21
21
  CSV.open(file_path,'w',
22
- :write_headers=> true,
22
+ :write_headers => true,
23
23
  :headers => ['Name','Value']
24
24
  ) do |csv|
25
25
  csv << ['foo', '0']
@@ -148,7 +148,7 @@ This example defines and uses a custom write converter to strip whitespace from
148
148
 
149
149
  ==== Recipe: Specify Multiple Write Converters
150
150
 
151
- Use option <tt>:write_converters</tt> and multiple custom coverters
151
+ Use option <tt>:write_converters</tt> and multiple custom converters
152
152
  to convert field values when generating \CSV.
153
153
 
154
154
  This example defines and uses two custom write converters to strip and upcase generated fields:
@@ -83,7 +83,7 @@ Use instance method CSV#each with option +headers+ to read a source \String one
83
83
  CSV.new(string, headers: true).each do |row|
84
84
  p row
85
85
  end
86
- Ouput:
86
+ Output:
87
87
  #<CSV::Row "Name":"foo" "Value":"0">
88
88
  #<CSV::Row "Name":"bar" "Value":"1">
89
89
  #<CSV::Row "Name":"baz" "Value":"2">
@@ -431,7 +431,7 @@ You can use multiple field converters in either of these ways:
431
431
 
432
432
  ===== Recipe: Specify Multiple Field Converters in Option +:converters+
433
433
 
434
- Apply multiple field converters by specifying them in option +:conveters+:
434
+ Apply multiple field converters by specifying them in option +:converters+:
435
435
  source = "Name,Value\nfoo,0\nbar,1.0\nbaz,2.0\n"
436
436
  parsed = CSV.parse(source, headers: true, converters: [:integer, :float])
437
437
  parsed['Value'] # => [0, 1.0, 2.0]
@@ -500,7 +500,7 @@ You can use multiple header converters in either of these ways:
500
500
 
501
501
  ===== Recipe: Specify Multiple Header Converters in Option :header_converters
502
502
 
503
- Apply multiple header converters by specifying them in option +:header_conveters+:
503
+ Apply multiple header converters by specifying them in option +:header_converters+:
504
504
  source = "Name,Value\nfoo,0\nbar,1.0\nbaz,2.0\n"
505
505
  parsed = CSV.parse(source, headers: true, header_converters: [:downcase, :symbol])
506
506
  parsed.headers # => [:name, :value]
@@ -16,7 +16,7 @@ class CSV
16
16
  @empty_value = options[:empty_value]
17
17
  @empty_value_is_empty_string = (@empty_value == "")
18
18
  @accept_nil = options[:accept_nil]
19
- @builtin_converters = options[:builtin_converters]
19
+ @builtin_converters_name = options[:builtin_converters_name]
20
20
  @need_static_convert = need_static_convert?
21
21
  end
22
22
 
@@ -24,7 +24,7 @@ class CSV
24
24
  if name.nil? # custom converter
25
25
  @converters << converter
26
26
  else # named converter
27
- combo = @builtin_converters[name]
27
+ combo = builtin_converters[name]
28
28
  case combo
29
29
  when Array # combo converter
30
30
  combo.each do |sub_name|
@@ -80,5 +80,9 @@ class CSV
80
80
  @need_static_convert or
81
81
  (not @converters.empty?)
82
82
  end
83
+
84
+ def builtin_converters
85
+ @builtin_converters ||= ::CSV.const_get(@builtin_converters_name)
86
+ end
83
87
  end
84
88
  end
@@ -0,0 +1,18 @@
1
+ require "English"
2
+ require "stringio"
3
+
4
+ class CSV
5
+ module InputRecordSeparator
6
+ class << self
7
+ if RUBY_VERSION >= "3.0.0"
8
+ def value
9
+ "\n"
10
+ end
11
+ else
12
+ def value
13
+ $INPUT_RECORD_SEPARATOR
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end