xsv 0.3.13 → 0.3.14

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: bdd18155c813e1b242f54bf1b9b5696334ec496058a65ce281950d5971b91450
4
- data.tar.gz: efb138a131f1e4799d26d823c3b3ddd45b34add899054d1cf8986b7d9143d26a
3
+ metadata.gz: a66b24ece17f7b9faa5135579c0af4d35304d621e853faca1e6d7d9690b89e6f
4
+ data.tar.gz: a198c842580d809434a07eca88926f0e3a427aa2c61f94c1cc6b8280f71a69a2
5
5
  SHA512:
6
- metadata.gz: 44a8ac8f904193b9a03db187a6bd7cb292793c1751261e063003d4a8bfcb61233f55c5303b22066dfb7d36f0b7519d238aee6023aa51793f30e0dab33d9f1491
7
- data.tar.gz: c1c00561d544eb4666e411fb6b59205ce242394005bdead120ef73e852d0fac03bf6ed929becbe1e819b3f8226535093dc25d42ed3a655dd892c57a2a4890828
6
+ metadata.gz: ccec619995f290348adb91cd5114b1829641e7623bf7715fea9a0de9787451d1393230cd69f225f340c463fcb53b595ca97dabf25cedcebfbc5f985d8bf60afa
7
+ data.tar.gz: f02eb4ea27c7e87634e11b626f5f7f9b5ad1f4068240428e52864798d08054c795ff78865cb1352a2dedc49d0f0933f51f6f3ac4dd598d72c2e510086d673ddd
data/.travis.yml CHANGED
@@ -4,8 +4,7 @@ language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
6
  - 2.5.8
7
- - 2.6.5
8
- - 2.7.0
7
+ - 2.7.1
9
8
  env:
10
9
  - "rubyzip=1.3.0"
11
10
  - "rubyzip=2.2.0"
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Xsv Changelog
2
2
 
3
- ## HEAD
3
+ ## 0.3.14 2020-05-22
4
+
5
+ - Allow opening workbooks from Tempfile and anything that responds to #read
6
+
7
+ - Preserve whitespace in text cells
8
+
9
+ ## 0.3.13 2020-05-12
4
10
 
5
11
  - Add Sheet#hidden?
6
12
 
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in xsv.gemspec
6
6
  gemspec
data/Rakefile CHANGED
@@ -14,4 +14,3 @@ Rake::TestTask.new(:bench) do |t|
14
14
  end
15
15
 
16
16
  task :default => [:test, :bench]
17
-
data/lib/xsv/helpers.rb CHANGED
@@ -39,7 +39,7 @@ module Xsv
39
39
 
40
40
  MINUTE = 60.freeze
41
41
  HOUR = 3600.freeze
42
- A_CODEPOINT = 'A'.ord.freeze
42
+ A_CODEPOINT = "A".ord.freeze
43
43
  # The epoch for all dates in OOXML Spreadsheet documents
44
44
  EPOCH = Date.new(1899, 12, 30).freeze
45
45
 
@@ -53,7 +53,7 @@ module Xsv
53
53
 
54
54
  # Return a Date for the given Excel date value
55
55
  def parse_date(number)
56
- EPOCH + number
56
+ EPOCH + number
57
57
  end
58
58
 
59
59
  # Return a time as a string for the given Excel time value
@@ -6,7 +6,7 @@ module Xsv
6
6
  def self.parse(io)
7
7
  strings = []
8
8
  handler = new { |s| strings << s }
9
- Ox.sax_parse(handler, io.read)
9
+ Ox.sax_parse(handler, io.read, skip: :skip_none)
10
10
  return strings
11
11
  end
12
12
 
@@ -7,8 +7,8 @@ module Xsv
7
7
  @xfs = nil
8
8
  @numFmts = nil
9
9
  handler = new(numFmts) do |xfs, numFmts|
10
- @xfs = xfs
11
- @numFmts = numFmts
10
+ @xfs = xfs
11
+ @numFmts = numFmts
12
12
  end
13
13
 
14
14
  Ox.sax_parse(handler, io.read)
data/lib/xsv/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Xsv
3
- VERSION = "0.3.13"
3
+ VERSION = "0.3.14"
4
4
  end
data/lib/xsv/workbook.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'zip'
2
+ require "zip"
3
3
 
4
4
  module Xsv
5
5
  # An OOXML Spreadsheet document is called a Workbook. A Workbook consists of
@@ -15,11 +15,11 @@ module Xsv
15
15
  # Open the workbook of the given filename, string or buffer. For additional
16
16
  # options see {.initialize}
17
17
  def self.open(data, **kws)
18
- if data.is_a?(IO)
18
+ if data.is_a?(IO) || data.respond_to?(:read) # is it a buffer?
19
19
  @workbook = self.new(Zip::File.open_buffer(data), **kws)
20
- elsif data.start_with?("PK\x03\x04")
20
+ elsif data.start_with?("PK\x03\x04") # is it a string containing a filename?
21
21
  @workbook = self.new(Zip::File.open_buffer(data), **kws)
22
- else
22
+ else # must be a filename
23
23
  @workbook = self.new(Zip::File.open(data), **kws)
24
24
  end
25
25
  end
@@ -91,7 +91,7 @@ module Xsv
91
91
  @zip.glob("xl/worksheets/sheet*.xml").sort do |a, b|
92
92
  a.name[/\d+/].to_i <=> b.name[/\d+/].to_i
93
93
  end.each do |entry|
94
- rel = @relationships.detect { |r| entry.name.end_with?(r[:Target]) && r[:Type].end_with?('worksheet') }
94
+ rel = @relationships.detect { |r| entry.name.end_with?(r[:Target]) && r[:Type].end_with?("worksheet") }
95
95
  sheet_ids = @sheets_ids.detect { |i| i[:r_id] == rel[:Id] }
96
96
  @sheets << Xsv::Sheet.new(self, entry.get_input_stream, entry.size, sheet_ids)
97
97
  end
data/lib/xsv.rb CHANGED
@@ -8,7 +8,7 @@ require "xsv/shared_strings_parser"
8
8
  require "xsv/sheet"
9
9
  require "xsv/sheet_bounds_handler"
10
10
  require "xsv/sheet_rows_handler"
11
- require 'xsv/sheets_ids_handler'
11
+ require "xsv/sheets_ids_handler"
12
12
  require "xsv/styles_handler"
13
13
  require "xsv/version"
14
14
  require "xsv/workbook"
@@ -19,6 +19,7 @@ require "xsv/workbook"
19
19
  # deals with minimal formatting and cannot create or modify documents.
20
20
  module Xsv
21
21
  class Error < StandardError; end
22
+
22
23
  # An AssertionFailed error indicates an unexpected condition, meaning a bug
23
24
  # or misinterpreted .xlsx document
24
25
  class AssertionFailed < StandardError; end
data/xsv.gemspec CHANGED
@@ -1,23 +1,22 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "xsv/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "xsv"
8
- spec.version = Xsv::VERSION
9
- spec.authors = ["Martijn Storck"]
10
- spec.email = ["martijn@storck.io"]
6
+ spec.name = "xsv"
7
+ spec.version = Xsv::VERSION
8
+ spec.authors = ["Martijn Storck"]
9
+ spec.email = ["martijn@storck.io"]
11
10
 
12
- spec.summary = "A fast and lightweiggt xlsx parser that provides nothing a CSV parser wouldn't"
13
- spec.description = <<-EOF
11
+ spec.summary = "A fast and lightweiggt xlsx parser that provides nothing a CSV parser wouldn't"
12
+ spec.description = <<-EOF
14
13
  Xsv is a fast, lightweight parser for Office Open XML spreadsheet files
15
14
  (commonly known as Excel or .xlsx files). It strives to be minimal in the
16
15
  sense that it provides nothing a CSV reader wouldn't, meaning it only
17
16
  deals with minimal formatting and cannot create or modify documents.
18
17
  EOF
19
- spec.homepage = "https://github.com/martijn/xsv"
20
- spec.license = "MIT"
18
+ spec.homepage = "https://github.com/martijn/xsv"
19
+ spec.license = "MIT"
21
20
 
22
21
  if spec.respond_to?(:metadata)
23
22
  spec.metadata["homepage_uri"] = spec.homepage
@@ -25,19 +24,19 @@ Gem::Specification.new do |spec|
25
24
  spec.metadata["changelog_uri"] = "https://github.com/martijn/xsv/CHANGELOG.md"
26
25
  else
27
26
  raise "RubyGems 2.0 or newer is required to protect against " \
28
- "public gem pushes."
27
+ "public gem pushes."
29
28
  end
30
29
 
31
30
  # Specify which files should be added to the gem when it is released.
32
31
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
34
33
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
34
  end
36
- spec.bindir = "exe"
37
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
37
  spec.require_paths = ["lib"]
39
38
 
40
- spec.required_ruby_version = '~> 2.5'
39
+ spec.required_ruby_version = "~> 2.5"
41
40
 
42
41
  spec.add_dependency "rubyzip", ">= 1.3", "< 3"
43
42
  spec.add_dependency "ox", ">= 2.9"
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: 0.3.13
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martijn Storck
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -117,7 +117,6 @@ files:
117
117
  - lib/xsv/styles_handler.rb
118
118
  - lib/xsv/version.rb
119
119
  - lib/xsv/workbook.rb
120
- - test.sh
121
120
  - xsv.gemspec
122
121
  homepage: https://github.com/martijn/xsv
123
122
  licenses:
data/test.sh DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/sh
2
-
3
- ruby -Ilib:test test/*_test.rb