xsv 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -4
- data/lib/xsv/sax_parser.rb +18 -5
- data/lib/xsv/sheets_ids_handler.rb +1 -1
- data/lib/xsv/version.rb +1 -1
- data/lib/xsv/workbook.rb +5 -2
- data/xsv.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2cc530ad96a5351ea6ab8a8b9d0f2ee9df0e1827a98e4244f239b3658bc2145
|
4
|
+
data.tar.gz: e286d74163ea3524dfcbd92553c0c4254b667e4ea13adae7468c0d1dc4c8089b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a89e58bc0447ecbd2eefdd81fe978a5e38438296bcce9dbf18b4dbc3fea5d5740016e35237d229fbab8201bb0e71b208ca66858c9d61e85f4d31d729e9048054
|
7
|
+
data.tar.gz: 45ddf90be0abe97dcd8aac6b08b9daeac2f68f7634062655efee6f59fbef50c6aad3eb69a461b4f7fcf9dd2751fa735de82e9a0821ec18d2f45cb4bada591698
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Xsv .xlsx reader
|
2
2
|
|
3
|
-
|
4
|
-
[![
|
5
|
-
[![
|
6
|
-
[![
|
3
|
+
|
4
|
+
[![Test badge](https://img.shields.io/github/workflow/status/martijn/xsv/Ruby/main)](https://github.com/martijn/xsv/actions/workflows/ruby.yml)
|
5
|
+
[![Codecov badge](https://img.shields.io/codecov/c/github/martijn/xsv/main)](https://app.codecov.io/gh/martijn/xsv)
|
6
|
+
[![Yard Docs badge](http://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/martijn/xsv)
|
7
|
+
[![Gem Version badge](https://badge.fury.io/rb/xsv.svg)](https://badge.fury.io/rb/xsv)
|
7
8
|
|
8
9
|
Xsv is a fast, lightweight, pure Ruby parser for ISO/IEC 29500 Office Open XML spreadsheet files
|
9
10
|
(commonly known as Excel or .xlsx files). It strives to be minimal in the
|
data/lib/xsv/sax_parser.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Xsv
|
4
4
|
class SaxParser
|
5
|
-
ATTR_REGEX = /((\
|
5
|
+
ATTR_REGEX = /((\p{Alnum}+)="(.*?)")/mn
|
6
6
|
|
7
7
|
def parse(io)
|
8
8
|
responds_to_end_element = respond_to?(:end_element)
|
@@ -67,13 +67,15 @@ module Xsv
|
|
67
67
|
args = nil
|
68
68
|
end
|
69
69
|
|
70
|
+
stripped_tag_name = strip_namespace(tag_name)
|
71
|
+
|
70
72
|
if tag_name.start_with?("/")
|
71
|
-
end_element(tag_name[1..]) if responds_to_end_element
|
73
|
+
end_element(strip_namespace(tag_name[1..])) if responds_to_end_element
|
72
74
|
elsif args.nil?
|
73
|
-
start_element(
|
75
|
+
start_element(stripped_tag_name, nil)
|
74
76
|
else
|
75
|
-
start_element(
|
76
|
-
end_element(
|
77
|
+
start_element(stripped_tag_name, args.scan(ATTR_REGEX).each_with_object({}) { |(_, k, v), h| h[k.to_sym] = v })
|
78
|
+
end_element(stripped_tag_name) if responds_to_end_element && args.end_with?("/")
|
77
79
|
end
|
78
80
|
|
79
81
|
state = :look_start
|
@@ -85,5 +87,16 @@ module Xsv
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
# I am not proud of this, but there's simply no need to deal with xmlns for this application ¯\_(ツ)_/¯
|
94
|
+
def strip_namespace(tag)
|
95
|
+
if (offset = tag.index(":"))
|
96
|
+
tag[offset + 1..]
|
97
|
+
else
|
98
|
+
tag
|
99
|
+
end
|
100
|
+
end
|
88
101
|
end
|
89
102
|
end
|
data/lib/xsv/version.rb
CHANGED
data/lib/xsv/workbook.rb
CHANGED
@@ -93,8 +93,11 @@ module Xsv
|
|
93
93
|
@zip.glob("xl/worksheets/sheet*.xml").sort do |a, b|
|
94
94
|
a.name[/\d+/].to_i <=> b.name[/\d+/].to_i
|
95
95
|
end.map do |entry|
|
96
|
-
rel = @relationships.detect
|
97
|
-
|
96
|
+
rel = @relationships.detect do |r|
|
97
|
+
entry.name.end_with?(r[:Target].sub(/^\//, "")) && # ignore leading / in some files
|
98
|
+
r[:Type].end_with?("worksheet")
|
99
|
+
end
|
100
|
+
sheet_ids = @sheet_ids.detect { |i| i[:id] == rel[:Id] }
|
98
101
|
Xsv::Sheet.new(self, entry.get_input_stream, entry.size, sheet_ids).tap do |sheet|
|
99
102
|
sheet.parse_headers! if mode == :hash
|
100
103
|
end
|
data/xsv.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
if spec.respond_to?(:metadata)
|
22
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
23
23
|
spec.metadata["source_code_uri"] = "https://github.com/martijn/xsv"
|
24
|
-
spec.metadata["changelog_uri"] = "https://
|
24
|
+
spec.metadata["changelog_uri"] = "https://raw.githubusercontent.com/martijn/xsv/main/CHANGELOG.md"
|
25
25
|
else
|
26
26
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
27
|
"public gem pushes."
|
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.1.
|
4
|
+
version: 1.1.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: 2022-
|
11
|
+
date: 2022-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -141,7 +141,7 @@ licenses:
|
|
141
141
|
metadata:
|
142
142
|
homepage_uri: https://github.com/martijn/xsv
|
143
143
|
source_code_uri: https://github.com/martijn/xsv
|
144
|
-
changelog_uri: https://
|
144
|
+
changelog_uri: https://raw.githubusercontent.com/martijn/xsv/main/CHANGELOG.md
|
145
145
|
post_install_message:
|
146
146
|
rdoc_options: []
|
147
147
|
require_paths:
|