csv 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +47 -0
- data/lib/csv.rb +399 -379
- data/lib/csv/core_ext/array.rb +1 -1
- data/lib/csv/core_ext/string.rb +1 -1
- data/lib/csv/fields_converter.rb +6 -0
- data/lib/csv/parser.rb +52 -8
- data/lib/csv/row.rb +17 -15
- data/lib/csv/table.rb +29 -29
- data/lib/csv/version.rb +1 -1
- data/lib/csv/writer.rb +12 -0
- metadata +2 -2
data/lib/csv/version.rb
CHANGED
data/lib/csv/writer.rb
CHANGED
@@ -6,7 +6,12 @@ require_relative "row"
|
|
6
6
|
using CSV::MatchP if CSV.const_defined?(:MatchP)
|
7
7
|
|
8
8
|
class CSV
|
9
|
+
# Note: Don't use this class directly. This is an internal class.
|
9
10
|
class Writer
|
11
|
+
#
|
12
|
+
# A CSV::Writer receives an output, prepares the header, format and output.
|
13
|
+
# It allows us to write new rows in the object and rewind it.
|
14
|
+
#
|
10
15
|
attr_reader :lineno
|
11
16
|
attr_reader :headers
|
12
17
|
|
@@ -14,6 +19,7 @@ class CSV
|
|
14
19
|
@output = output
|
15
20
|
@options = options
|
16
21
|
@lineno = 0
|
22
|
+
@fields_converter = nil
|
17
23
|
prepare
|
18
24
|
if @options[:write_headers] and @headers
|
19
25
|
self << @headers
|
@@ -21,6 +27,9 @@ class CSV
|
|
21
27
|
@fields_converter = @options[:fields_converter]
|
22
28
|
end
|
23
29
|
|
30
|
+
#
|
31
|
+
# Adds a new row
|
32
|
+
#
|
24
33
|
def <<(row)
|
25
34
|
case row
|
26
35
|
when Row
|
@@ -46,6 +55,9 @@ class CSV
|
|
46
55
|
self
|
47
56
|
end
|
48
57
|
|
58
|
+
#
|
59
|
+
# Winds back to the beginning
|
60
|
+
#
|
49
61
|
def rewind
|
50
62
|
@lineno = 0
|
51
63
|
@headers = nil if @options[:headers].nil?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Edward Gray II
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|