xsv 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ff63ab6263b0486a400d5d36eb53d0af7265532b67536c7024b414b2bcf3ad2
4
- data.tar.gz: a885af30f1a874818bb80f984115d7bc47e178007bf9848407e279af3effcd3b
3
+ metadata.gz: 9f753b006d8a3c230447e56b70824c7df929c5b7bd074ec82cf82acdf971073c
4
+ data.tar.gz: bb457169f14d259526443ff2afa47477dceb13edf13d99f089e2f843f9fa258f
5
5
  SHA512:
6
- metadata.gz: 37b9b49b66fcec0c393a56382b162d0fb3c77e2342798292d3a4c73c49939ce3d0827c783a7b9b5c139b52553e3a622f6e47f510e4839963609c571e7ab53067
7
- data.tar.gz: ecd5e49c82d802e2a654c7d6321cdf81b5ea81482a83821ca6ddd19ae5036a6e2a516569356ded600b2181b0c4161c5c7e4e36a43570b4bef82f7c9d58038392
6
+ metadata.gz: e3686372d118d3d3ca17c403e34479ab00168f0ba5b2057b624cf0b90ed4ee28caf7f9237201c5f6649a7435adc2b77e29751eeec90a71ec577acfcbca2ff0b2
7
+ data.tar.gz: '094d7b47e71c7ad96b1a477e672c2615203f814cc475cc6194772e8e048713d36e58780c9dbe17a2239a4a63869eea3cde8cbcc20a7dd07816cde9519ff6a2e7'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Xsv Changelog
2
2
 
3
+ ## 1.3.1 2023-05-06
4
+
5
+ - Fix issue #56 with multiple nil headers
6
+ - Ignore colums with a `nil` header in hash mode
7
+
3
8
  ## 1.3.0 2023-12-16
4
9
 
5
10
  - Ruby 2.6 is no longer supported. Xsv is compatible with Ruby 2.7 through 3.3, latest JRuby, and latest TruffleRuby
data/lib/xsv/sheet.rb CHANGED
@@ -56,7 +56,7 @@ module Xsv
56
56
  # Iterate over rows, returning either hashes or arrays based on the current mode.
57
57
  def each_row(&block)
58
58
  @io.rewind
59
- SheetRowsHandler.new(@mode, empty_row, @workbook, @row_skip, @last_row, &block).parse(@io)
59
+ SheetRowsHandler.new(@mode, @headers, empty_row, @workbook, @row_skip, @last_row, &block).parse(@io)
60
60
  true
61
61
  end
62
62
 
@@ -114,7 +114,7 @@ module Xsv
114
114
  when :array
115
115
  [nil] * @column_count
116
116
  when :hash
117
- @headers.zip([]).to_h
117
+ @headers.compact.zip([]).to_h
118
118
  end
119
119
  end
120
120
  end
@@ -6,8 +6,9 @@ module Xsv
6
6
  class SheetRowsHandler < SaxParser
7
7
  include Xsv::Helpers
8
8
 
9
- def initialize(mode, empty_row, workbook, row_skip, last_row, &block)
9
+ def initialize(mode, headers, empty_row, workbook, row_skip, last_row, &block)
10
10
  @mode = mode
11
+ @headers = headers
11
12
  @empty_row = empty_row
12
13
  @workbook = workbook
13
14
  @row_skip = row_skip
@@ -22,8 +23,6 @@ module Xsv
22
23
  @current_row_number = 0
23
24
  @current_cell = {}
24
25
  @current_value = +""
25
-
26
- @headers = @empty_row.keys if @mode == :hash
27
26
  end
28
27
 
29
28
  def start_element(name, attrs)
@@ -34,7 +33,7 @@ module Xsv
34
33
  when "v", "is", "t"
35
34
  @store_characters = true
36
35
  when "row"
37
- @current_row = @mode == :array ? [] : @empty_row.dup
36
+ @current_row = (@mode == :array) ? [] : @empty_row.dup
38
37
  @current_row_number = attrs[:r].to_i
39
38
  end
40
39
  end
@@ -53,7 +52,7 @@ module Xsv
53
52
  if @mode == :array
54
53
  @current_row[col_index] = format_cell
55
54
  else
56
- @current_row[@headers[col_index]] = format_cell
55
+ @current_row[@headers[col_index]] = format_cell unless @headers[col_index].nil?
57
56
  end
58
57
 
59
58
  @col_index += 1
data/lib/xsv/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xsv
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xsv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martijn Storck
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-16 00:00:00.000000000 Z
11
+ date: 2024-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip