csv 3.2.2 → 3.3.5

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.
@@ -4,6 +4,13 @@ class CSV
4
4
  # Note: Don't use this class directly. This is an internal class.
5
5
  class FieldsConverter
6
6
  include Enumerable
7
+
8
+ NO_QUOTED_FIELDS = [] # :nodoc:
9
+ def NO_QUOTED_FIELDS.[](_index)
10
+ false
11
+ end
12
+ NO_QUOTED_FIELDS.freeze
13
+
7
14
  #
8
15
  # A CSV::FieldsConverter is a data structure for storing the
9
16
  # fields converter properties to be passed as a parameter
@@ -44,7 +51,7 @@ class CSV
44
51
  @converters.empty?
45
52
  end
46
53
 
47
- def convert(fields, headers, lineno)
54
+ def convert(fields, headers, lineno, quoted_fields=NO_QUOTED_FIELDS)
48
55
  return fields unless need_convert?
49
56
 
50
57
  fields.collect.with_index do |field, index|
@@ -63,7 +70,8 @@ class CSV
63
70
  else
64
71
  header = nil
65
72
  end
66
- field = converter[field, FieldInfo.new(index, lineno, header)]
73
+ quoted = quoted_fields[index]
74
+ field = converter[field, FieldInfo.new(index, lineno, header, quoted)]
67
75
  end
68
76
  break unless field.is_a?(String) # short-circuit pipeline for speed
69
77
  end
@@ -4,20 +4,7 @@ require "stringio"
4
4
  class CSV
5
5
  module InputRecordSeparator
6
6
  class << self
7
- is_input_record_separator_deprecated = false
8
- verbose, $VERBOSE = $VERBOSE, true
9
- stderr, $stderr = $stderr, StringIO.new
10
- input_record_separator = $INPUT_RECORD_SEPARATOR
11
- begin
12
- $INPUT_RECORD_SEPARATOR = "\r\n"
13
- is_input_record_separator_deprecated = (not $stderr.string.empty?)
14
- ensure
15
- $INPUT_RECORD_SEPARATOR = input_record_separator
16
- $stderr = stderr
17
- $VERBOSE = verbose
18
- end
19
-
20
- if is_input_record_separator_deprecated
7
+ if RUBY_VERSION >= "3.0.0"
21
8
  def value
22
9
  "\n"
23
10
  end