csv 3.1.2 → 3.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30015ee78d9fd5fa7b6bc0bbca7b785adef465e39dd654d4c4a020420f2f47ec
4
- data.tar.gz: 72ece87ac30a9748dc64b37c8ca77de23b21939c19568c870b9ccb020f8cabf4
3
+ metadata.gz: 287ad200c61c1756e9386a9d910c9e16c3f876e3860d7a147d82ef3d2017ca72
4
+ data.tar.gz: 98d1b16dfad00c08f5b07e0beb0d535c3e1777d9e01ecca9a2d21c2e5665eefb
5
5
  SHA512:
6
- metadata.gz: '09cdbbeb0d72c765d3cd15e690dfb6a25a7e731f5d79f15815cdc17cbb074c5d592d4805f9e59778f911478ea25dc635ee91a43210e8720e8c996166bbe4467c'
7
- data.tar.gz: 8144fa3744620a731ff8b601316e476c6263a9928db41fa95ef50902d20928e1be174fbe115d42585a46dc455971e65fe1abc82032a9f6d82c959a675b1e252f
6
+ metadata.gz: f0d55f65f559d083f570a3f72f27d5123c961cad244ea6b0b098c9f3e806474a5a8fc4335ada22f9031fa37664c05229428c6630ecc800709a7e0c90b72514ab
7
+ data.tar.gz: 97f936a5e13547f9c362c66617f36ae9e3e84c7e611b105ea40b0f59442cec165d9382aa34a6c9eebb16b365c2fa12620d839396a2041ad0a97c878ed86a1da3
data/NEWS.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # News
2
2
 
3
+ ## 3.1.3 - 2020-05-09
4
+
5
+ ### Improvements
6
+
7
+ * `CSV::Row#dup`: Copied deeply.
8
+ [GitHub#108][Patch by Jim Kane]
9
+
10
+ ### Fixes
11
+
12
+ * Fixed a infinite loop bug for zero length match `skip_lines`.
13
+ [GitHub#110][Patch by Mike MacDonald]
14
+
15
+ * `CSV.generate`: Fixed a bug that encoding isn't set correctly.
16
+ [GitHub#110][Patch by Seiei Miyagi]
17
+
18
+ * Fixed document for the `:strip` option.
19
+ [GitHub#114][Patch by TOMITA Masahiro]
20
+
21
+ * Fixed a parse bug when split charcter exists in middle of column
22
+ value.
23
+ [GitHub#115][Reported by TOMITA Masahiro]
24
+
25
+ ### Thanks
26
+
27
+ * Jim Kane
28
+
29
+ * Mike MacDonald
30
+
31
+ * Seiei Miyagi
32
+
33
+ * TOMITA Masahiro
34
+
3
35
  ## 3.1.2 - 2019-10-12
4
36
 
5
37
  ### Improvements
data/lib/csv.rb CHANGED
@@ -531,12 +531,13 @@ class CSV
531
531
  # plan to output non-ASCII compatible data.
532
532
  #
533
533
  def generate(str=nil, **options)
534
+ encoding = options[:encoding]
534
535
  # add a default empty String, if none was given
535
536
  if str
536
537
  str = StringIO.new(str)
537
538
  str.seek(0, IO::SEEK_END)
539
+ str.set_encoding(encoding) if encoding
538
540
  else
539
- encoding = options[:encoding]
540
541
  str = +""
541
542
  str.force_encoding(encoding) if encoding
542
543
  end
@@ -908,7 +909,7 @@ class CSV
908
909
  # empty value(s) on each line will be
909
910
  # replaced with the specified value.
910
911
  # <b><tt>:strip</tt></b>:: When setting a +true+ value, CSV will
911
- # strip "\t\r\n\f\v" around the values.
912
+ # strip " \t\f\v" around the values.
912
913
  # If you specify a string instead of
913
914
  # +true+, CSV will strip string. The
914
915
  # length of the string must be 1.
@@ -1326,7 +1327,7 @@ class CSV
1326
1327
  # ASCII compatible String.
1327
1328
  #
1328
1329
  def inspect
1329
- str = ["<#", self.class.to_s, " io_type:"]
1330
+ str = ["#<", self.class.to_s, " io_type:"]
1330
1331
  # show type of wrapped IO
1331
1332
  if @io == $stdout then str << "$stdout"
1332
1333
  elsif @io == $stdin then str << "$stdin"
@@ -446,6 +446,7 @@ class CSV
446
446
  @strip = @options[:strip]
447
447
  @escaped_strip = nil
448
448
  @strip_value = nil
449
+ @rstrip_value = nil
449
450
  if @strip.is_a?(String)
450
451
  case @strip.length
451
452
  when 0
@@ -460,6 +461,8 @@ class CSV
460
461
  if @quote_character
461
462
  @strip_value = Regexp.new(@escaped_strip +
462
463
  "+".encode(@encoding))
464
+ @rstrip_value = Regexp.new(@escaped_strip +
465
+ "+\\z".encode(@encoding))
463
466
  end
464
467
  @need_robust_parsing = true
465
468
  elsif @strip
@@ -467,6 +470,7 @@ class CSV
467
470
  @escaped_strip = strip_values.encode(@encoding)
468
471
  if @quote_character
469
472
  @strip_value = Regexp.new("[#{strip_values}]+".encode(@encoding))
473
+ @rstrip_value = Regexp.new("[#{strip_values}]+\\z".encode(@encoding))
470
474
  end
471
475
  @need_robust_parsing = true
472
476
  end
@@ -561,9 +565,6 @@ class CSV
561
565
  unless @liberal_parsing
562
566
  no_unquoted_values << @escaped_quote_character
563
567
  end
564
- if @escaped_strip
565
- no_unquoted_values << @escaped_strip
566
- end
567
568
  @unquoted_value = Regexp.new("[^".encode(@encoding) +
568
569
  no_unquoted_values +
569
570
  "]+".encode(@encoding))
@@ -769,7 +770,7 @@ class CSV
769
770
  def skip_needless_lines
770
771
  return unless @skip_lines
771
772
 
772
- while true
773
+ until @scanner.eos?
773
774
  @scanner.keep_start
774
775
  line = @scanner.scan_all(@not_line_end) || "".encode(@encoding)
775
776
  line << @row_separator if parse_row_end
@@ -939,6 +940,7 @@ class CSV
939
940
  if @liberal_parsing
940
941
  quoted_value = parse_quoted_column_value
941
942
  if quoted_value
943
+ @scanner.scan_all(@strip_value) if @strip_value
942
944
  unquoted_value = parse_unquoted_column_value
943
945
  if unquoted_value
944
946
  if @double_quote_outside_quote
@@ -986,6 +988,9 @@ class CSV
986
988
  end
987
989
  end
988
990
  value.gsub!(@backslash_quote_character, @quote_character) if @backslash_quote
991
+ if @rstrip_value
992
+ value.gsub!(@rstrip_value, "")
993
+ end
989
994
  value
990
995
  end
991
996
 
@@ -50,7 +50,7 @@ class CSV
50
50
 
51
51
  def initialize_copy(other)
52
52
  super
53
- @row = @row.dup
53
+ @row = @row.collect(&:dup)
54
54
  end
55
55
 
56
56
  # Returns +true+ if this is a header row.
@@ -2,5 +2,5 @@
2
2
 
3
3
  class CSV
4
4
  # The version of the installed library.
5
- VERSION = "3.1.2"
5
+ VERSION = "3.1.3"
6
6
  end
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.2
4
+ version: 3.1.3
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-10-11 00:00:00.000000000 Z
12
+ date: 2020-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -110,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.7.6.2
113
+ rubygems_version: 3.2.0.pre1
115
114
  signing_key:
116
115
  specification_version: 4
117
116
  summary: CSV Reading and Writing