summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-05 13:33:21 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-05 13:33:21 +0000
commit60ebd4e26a1b6ed3ad11bade520db0a19e9be190 (patch)
tree7fd02799a27da1ab9c7f57ab5705100c4dab1d3b /lib
parent21ce539f20b1376ab4644f9620b0cd1487ae99d6 (diff)
Merge csv-3.0.0 from ruby/csv repository.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/csv.rb12
-rw-r--r--lib/csv/csv.gemspec9
-rw-r--r--lib/csv/row.rb5
-rw-r--r--lib/csv/table.rb2
-rw-r--r--lib/csv/version.rb2
5 files changed, 22 insertions, 8 deletions
diff --git a/lib/csv.rb b/lib/csv.rb
index ebb6d67968..dca2a45b6a 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -141,7 +141,7 @@ end
# There are several specialized class methods for one-statement reading or writing,
# described in the Specialized Methods section.
#
-# If a String passed into ::new, it is internally wrapped into a StringIO object.
+# If a String is passed into ::new, it is internally wrapped into a StringIO object.
#
# +options+ can be used for specifying the particular CSV flavor (column
# separators, row separators, value quoting and so on), and for data conversion,
@@ -890,8 +890,12 @@ class CSV
# attempt to parse input not conformant
# with RFC 4180, such as double quotes
# in unquoted fields.
- # <b><tt>:nil_value</tt></b>:: TODO: WRITE ME.
- # <b><tt>:empty_value</tt></b>:: TODO: WRITE ME.
+ # <b><tt>:nil_value</tt></b>:: When set an object, any values of an
+ # empty field are replaced by the set
+ # object, not nil.
+ # <b><tt>:empty_value</tt></b>:: When set an object, any values of a
+ # blank string field is replaced by
+ # the set object.
#
# See CSV::DEFAULT_OPTIONS for the default settings.
#
@@ -1232,7 +1236,7 @@ class CSV
elsif @unconverted_fields
return add_unconverted_fields(Array.new, Array.new)
elsif @use_headers
- return self.class::Row.new(Array.new, Array.new)
+ return self.class::Row.new(@headers, Array.new)
else
return Array.new
end
diff --git a/lib/csv/csv.gemspec b/lib/csv/csv.gemspec
index 0169c173d6..9d0ccc15af 100644
--- a/lib/csv/csv.gemspec
+++ b/lib/csv/csv.gemspec
@@ -1,6 +1,10 @@
# frozen_string_literal: true
-require_relative "version"
+begin
+ require_relative "lib/csv/version"
+rescue LoadError
+ require_relative "version"
+end
Gem::Specification.new do |spec|
spec.name = "csv"
@@ -13,7 +17,8 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/ruby/csv"
spec.license = "BSD-2-Clause"
- spec.files = ["lib/csv.rb", "lib/csv/table.rb", "lib/csv/core_ext/string.rb", "lib/csv/core_ext/array.rb", "lib/csv/row.rb", "lib/csv/version.rb", "README.md", "LICENSE.txt", "news.md"]
+ spec.files = Dir.glob("lib/**/*.rb")
+ spec.files += ["README.md", "LICENSE.txt", "news.md"]
spec.require_paths = ["lib"]
spec.required_ruby_version = ">= 2.3.0"
diff --git a/lib/csv/row.rb b/lib/csv/row.rb
index 8ff3480ae8..31eab2d0a4 100644
--- a/lib/csv/row.rb
+++ b/lib/csv/row.rb
@@ -48,6 +48,11 @@ class CSV
extend Forwardable
def_delegators :@row, :empty?, :length, :size
+ def initialize_copy(other)
+ super
+ @row = @row.dup
+ end
+
# Returns +true+ if this is a header row.
def header_row?
@header_row
diff --git a/lib/csv/table.rb b/lib/csv/table.rb
index 17a7c542e4..e9f3366a4a 100644
--- a/lib/csv/table.rb
+++ b/lib/csv/table.rb
@@ -375,4 +375,4 @@ class CSV
"#<#{self.class} mode:#{@mode} row_count:#{to_a.size}>".encode("US-ASCII")
end
end
-end
+end \ No newline at end of file
diff --git a/lib/csv/version.rb b/lib/csv/version.rb
index 35adea3a92..d62a093418 100644
--- a/lib/csv/version.rb
+++ b/lib/csv/version.rb
@@ -2,5 +2,5 @@
class CSV
# The version of the installed library.
- VERSION = "1.0.2"
+ VERSION = "3.0.1"
end