diff options
Diffstat (limited to 'doc/csv/options')
-rw-r--r-- | doc/csv/options/common/col_sep.rdoc | 6 | ||||
-rw-r--r-- | doc/csv/options/common/row_sep.rdoc | 9 | ||||
-rw-r--r-- | doc/csv/options/generating/write_converters.rdoc | 8 | ||||
-rw-r--r-- | doc/csv/options/generating/write_headers.rdoc | 2 | ||||
-rw-r--r-- | doc/csv/options/parsing/liberal_parsing.rdoc | 23 |
5 files changed, 22 insertions, 26 deletions
diff --git a/doc/csv/options/common/col_sep.rdoc b/doc/csv/options/common/col_sep.rdoc index 05769b5773..3f23c6d2d3 100644 --- a/doc/csv/options/common/col_sep.rdoc +++ b/doc/csv/options/common/col_sep.rdoc @@ -55,9 +55,3 @@ Raises an exception if parsing with the empty \String: # Raises ArgumentError (:col_sep must be 1 or more characters: "") CSV.parse("foo0\nbar1\nbaz2\n", col_sep: col_sep) -Raises an exception if the given value is not String-convertible: - col_sep = BasicObject.new - # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>) - CSV.generate(line, col_sep: col_sep) - # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>) - CSV.parse(str, col_sep: col_sep) diff --git a/doc/csv/options/common/row_sep.rdoc b/doc/csv/options/common/row_sep.rdoc index 872d9d1f3f..eae15b4a84 100644 --- a/doc/csv/options/common/row_sep.rdoc +++ b/doc/csv/options/common/row_sep.rdoc @@ -89,12 +89,3 @@ if any of the following is true: * The stream is only available for output. Obviously, discovery takes a little time. Set manually if speed is important. Also note that IO objects should be opened in binary mode on Windows if this feature will be used as the line-ending translation can cause problems with resetting the document position to where it was before the read ahead. - ---- - -Raises an exception if the given value is not String-convertible: - row_sep = BasicObject.new - # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>) - CSV.generate(ary, row_sep: row_sep) - # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>) - CSV.parse(str, row_sep: row_sep) diff --git a/doc/csv/options/generating/write_converters.rdoc b/doc/csv/options/generating/write_converters.rdoc index 6e5fae5fda..d1a9cc748f 100644 --- a/doc/csv/options/generating/write_converters.rdoc +++ b/doc/csv/options/generating/write_converters.rdoc @@ -23,11 +23,3 @@ With two write converters (called in order): str # => "a,b,c\n" See also {Write Converters}[#class-CSV-label-Write+Converters] - ---- - -Raises an exception if the converter returns a value that is neither +nil+ -nor \String-convertible: - bad_converter = proc {|field| BasicObject.new } - # Raises NoMethodError (undefined method `is_a?' for #<BasicObject:>) - CSV.generate_line(['a', 'b', 'c'], write_converters: bad_converter)
\ No newline at end of file diff --git a/doc/csv/options/generating/write_headers.rdoc b/doc/csv/options/generating/write_headers.rdoc index f9faa9d438..c56aa48adb 100644 --- a/doc/csv/options/generating/write_headers.rdoc +++ b/doc/csv/options/generating/write_headers.rdoc @@ -19,7 +19,7 @@ Without +write_headers+: With +write_headers+": CSV.open(file_path,'w', - :write_headers=> true, + :write_headers => true, :headers => ['Name','Value'] ) do |csv| csv << ['foo', '0'] diff --git a/doc/csv/options/parsing/liberal_parsing.rdoc b/doc/csv/options/parsing/liberal_parsing.rdoc index b8b9b00c98..603de28613 100644 --- a/doc/csv/options/parsing/liberal_parsing.rdoc +++ b/doc/csv/options/parsing/liberal_parsing.rdoc @@ -1,13 +1,13 @@ ====== Option +liberal_parsing+ -Specifies the boolean value that determines whether +Specifies the boolean or hash value that determines whether CSV will attempt to parse input not conformant with RFC 4180, such as double quotes in unquoted fields. Default value: CSV::DEFAULT_OPTIONS.fetch(:liberal_parsing) # => false -For examples in this section: +For the next two examples: str = 'is,this "three, or four",fields' Without +liberal_parsing+: @@ -17,3 +17,22 @@ Without +liberal_parsing+: With +liberal_parsing+: ary = CSV.parse_line(str, liberal_parsing: true) ary # => ["is", "this \"three", " or four\"", "fields"] + +Use the +backslash_quote+ sub-option to parse values that use +a backslash to escape a double-quote character. This +causes the parser to treat <code>\"</code> as if it were +<code>""</code>. + +For the next two examples: + str = 'Show,"Harry \"Handcuff\" Houdini, the one and only","Tampa Theater"' + +With +liberal_parsing+, but without the +backslash_quote+ sub-option: + # Incorrect interpretation of backslash; incorrectly interprets the quoted comma as a field separator. + ary = CSV.parse_line(str, liberal_parsing: true) + ary # => ["Show", "\"Harry \\\"Handcuff\\\" Houdini", " the one and only\"", "Tampa Theater"] + puts ary[1] # => "Harry \"Handcuff\" Houdini + +With +liberal_parsing+ and its +backslash_quote+ sub-option: + ary = CSV.parse_line(str, liberal_parsing: { backslash_quote: true }) + ary # => ["Show", "Harry \"Handcuff\" Houdini, the one and only", "Tampa Theater"] + puts ary[1] # => Harry "Handcuff" Houdini, the one and only |