xsv 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/xsv/helpers.rb +5 -8
- data/lib/xsv/shared_strings_parser.rb +1 -0
- data/lib/xsv/sheet.rb +2 -1
- data/lib/xsv/sheet_bounds_handler.rb +1 -0
- data/lib/xsv/sheet_rows_handler.rb +3 -2
- data/lib/xsv/styles_handler.rb +1 -0
- data/lib/xsv/version.rb +2 -1
- data/lib/xsv/workbook.rb +4 -3
- data/lib/xsv.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fde081e219b3d4ae14aaa9d29de699e67df263ff0d8bfa1ffc10362099dc8eb
|
4
|
+
data.tar.gz: f2cd6e1ae40a06bcac62368a26f9cf09157d5394bbb7f9ab34473a90be729d37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24a1070748166f3d18fffced8b310825efa72c121b4226ce588686c18eb07f80a8c328848b7f1c0915b4c002ea656916db263441dd2a442a60dd828e4ba8ccde
|
7
|
+
data.tar.gz: 01530b8f31bc60aafbeb36a563faff5958bf98577ae3a85e527e217c0c988a5b5d4ef7e614811cdd590402312835b7f60c50c0a94c4a77bc0543729e41c6e826
|
data/Gemfile.lock
CHANGED
data/lib/xsv/helpers.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Xsv
|
2
3
|
module Helpers
|
3
4
|
BUILT_IN_NUMBER_FORMATS = {
|
@@ -36,23 +37,19 @@ module Xsv
|
|
36
37
|
|
37
38
|
MINUTE = 60.freeze
|
38
39
|
HOUR = 3600.freeze
|
40
|
+
A_CODEPOINT = 'A'.ord.freeze
|
41
|
+
EPOCH = Date.new(1899, 12, 30).freeze
|
39
42
|
|
40
43
|
# Return the index number for the given Excel column name
|
41
44
|
def column_index(col)
|
42
45
|
col = col[/^[A-Z]+/]
|
43
46
|
|
44
|
-
|
45
|
-
while col.length > 0
|
46
|
-
val *= 26
|
47
|
-
val += (col[0].ord - "A".ord + 1)
|
48
|
-
col = col[1..-1]
|
49
|
-
end
|
50
|
-
return val - 1
|
47
|
+
col.each_codepoint.reduce(0) { |sum, n| sum * 26 + (n - A_CODEPOINT + 1) } - 1
|
51
48
|
end
|
52
49
|
|
53
50
|
# Return a Date for the given Excel date value
|
54
51
|
def parse_date(number)
|
55
|
-
|
52
|
+
EPOCH + number
|
56
53
|
end
|
57
54
|
|
58
55
|
# Return a time as a string for the given Excel time value
|
data/lib/xsv/sheet.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Xsv
|
2
3
|
class SheetRowsHandler < Ox::Sax
|
3
4
|
include Xsv::Helpers
|
@@ -58,7 +59,7 @@ module Xsv
|
|
58
59
|
when :c
|
59
60
|
@state = name
|
60
61
|
@current_cell = {}
|
61
|
-
@current_value =
|
62
|
+
@current_value = String.new
|
62
63
|
when :v
|
63
64
|
@state = name
|
64
65
|
when :row
|
@@ -72,7 +73,7 @@ module Xsv
|
|
72
73
|
|
73
74
|
def text(value)
|
74
75
|
if @state == :v
|
75
|
-
@current_value
|
76
|
+
@current_value << value
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
data/lib/xsv/styles_handler.rb
CHANGED
data/lib/xsv/version.rb
CHANGED
data/lib/xsv/workbook.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'zip'
|
2
3
|
|
3
4
|
module Xsv
|
@@ -8,11 +9,11 @@ module Xsv
|
|
8
9
|
# Open the workbook of the given filename, string or buffer
|
9
10
|
def self.open(data, **kws)
|
10
11
|
if data.is_a?(IO)
|
11
|
-
@workbook = self.new(Zip::File.open_buffer(data), kws)
|
12
|
+
@workbook = self.new(Zip::File.open_buffer(data), **kws)
|
12
13
|
elsif data.start_with?("PK\x03\x04")
|
13
|
-
@workbook = self.new(Zip::File.open_buffer(data), kws)
|
14
|
+
@workbook = self.new(Zip::File.open_buffer(data), **kws)
|
14
15
|
else
|
15
|
-
@workbook = self.new(Zip::File.open(data), kws)
|
16
|
+
@workbook = self.new(Zip::File.open(data), **kws)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
data/lib/xsv.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xsv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martijn Storck
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.1.2
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Minimal xlsx parser that provides nothing a CSV parser wouldn't
|