saxlsx 1.6.1 → 1.7.0

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
  SHA1:
3
- metadata.gz: 7dc32c3edddd79931a9aa2c524b797621542ab84
4
- data.tar.gz: 741e327689fe7525f0c2613c191c3c9e75a45d7a
3
+ metadata.gz: 5bc6b0c27db86c92575ab6d76e938718f987062b
4
+ data.tar.gz: d64e2b1bf4fad6173b4e6a6fdcc9f52af0b67be7
5
5
  SHA512:
6
- metadata.gz: 2f12ad7f5636ac9bf9a48f2d1b8d22f05e77ab2e40a44ebb314ced6f7d0390be7189ba774c2402c3ec278036ca9efd4489934fbea7a1c0d8d28817e2bd0be174
7
- data.tar.gz: ba0525a308e673c1ab5570545d9698349fab4324c1342c679b6ec8395940cf4ec7da09d2d4331450a486c712f377264bbc89514b551af2c1274bc2fef8fcac22
6
+ metadata.gz: d06a5f4ea511da6bc470d3ab7129dd63d0876de0f1470a8f0ef9ced9c4611dd9f0d0d6c2d6b8ff07e20ecb4d7e918bd2849ce4ccff3c854e001748cbcf51f691
7
+ data.tar.gz: c2e9c81ddc0ce05477f60d720eba7bf5b23f9afb37c9b75f69e779d9e4f1f185ac46b2da579fe3cb29d879eb3f6d8b9060d0539357238cbd2873dbad4f63a737
data/Gemfile CHANGED
@@ -3,10 +3,10 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in saxlsx.gemspec
4
4
  gemspec
5
5
 
6
- gem 'axlsx', '~> 2.1.0.pre'
7
- gem 'rubyXL'
8
- gem 'simple_xlsx_reader'
9
- gem 'creek'
10
- gem 'oxcelix'
11
- gem 'roo'
12
- gem 'dullard'
6
+ gem 'axlsx', github: 'randym/axlsx'
7
+ gem 'rubyXL', github: 'weshatheleopard/rubyXL'
8
+ gem 'simple_xlsx_reader', github: 'woahdae/simple_xlsx_reader'
9
+ gem 'creek', github: 'pythonicrubyist/creek'
10
+ gem 'oxcelix', github: 'gbiczo/oxcelix'
11
+ gem 'roo', github: 'roo-rb/roo'
12
+ gem 'dullard', github: 'thirtyseven/dullard'
data/README.md CHANGED
@@ -52,30 +52,30 @@ using `auto_format: false`.
52
52
  $ rake bench
53
53
  ```
54
54
 
55
- ruby 2.2.1 on OS X 10.10
55
+ ruby 2.4.1 on OS X 10.12
56
56
 
57
57
  ```
58
58
  Shared Strings
59
59
 
60
60
  user system total real
61
- creek 3.000000 0.070000 3.070000 ( 3.254653)
62
- dullard 2.070000 0.030000 2.100000 ( 2.109380)
63
- oxcelix 1.100000 0.020000 1.120000 ( 1.128109)
64
- roo 11.980000 0.350000 12.330000 ( 12.473732)
65
- rubyXL 3.560000 0.070000 3.630000 ( 3.641981)
66
- saxlsx 0.660000 0.040000 0.700000 ( 0.693199)
67
- simple_xlsx_reader 1.650000 0.030000 1.680000 ( 1.686309)
61
+ creek 2.310000 0.040000 2.350000 ( 2.414795)
62
+ dullard 1.660000 0.050000 1.710000 ( 1.753160)
63
+ oxcelix 1.100000 0.060000 1.160000 ( 1.169371)
64
+ roo 2.770000 0.120000 2.890000 ( 2.943509)
65
+ rubyXL 3.570000 0.090000 3.660000 ( 3.716661)
66
+ saxlsx 0.620000 0.040000 0.660000 ( 0.665471)
67
+ simple_xlsx_reader 1.590000 0.030000 1.620000 ( 1.643398)
68
68
 
69
69
  Inline Strings
70
70
 
71
71
  user system total real
72
- creek 2.960000 0.260000 3.220000 ( 3.304050)
73
- dullard 2.380000 0.220000 2.600000 ( 2.639881)
72
+ creek 2.840000 0.200000 3.040000 ( 3.335055)
73
+ dullard 2.200000 0.250000 2.450000 ( 2.613793)
74
74
  oxcelix ERROR
75
- roo 11.620000 0.260000 11.880000 ( 12.136643)
76
- rubyXL 4.060000 0.480000 4.540000 ( 4.612416)
77
- saxlsx 0.870000 0.210000 1.080000 ( 1.091133)
78
- simple_xlsx_reader 1.910000 0.040000 1.950000 ( 1.961555)
75
+ roo 3.550000 0.160000 3.710000 ( 3.749528)
76
+ rubyXL 3.890000 0.390000 4.280000 ( 4.340749)
77
+ saxlsx 0.930000 0.240000 1.170000 ( 1.173783)
78
+ simple_xlsx_reader 1.760000 0.040000 1.800000 ( 1.818311)
79
79
  ```
80
80
 
81
81
  ## Contributing
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ Bundler::GemHelper.install_tasks
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  task :default => :spec
7
7
 
8
-
9
8
  task :bench do
10
9
  require './spec/benchmarks.rb'
11
10
  Saxlsx::Benchmarks.new.run
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bigdecimal'
2
3
  require 'rational'
3
4
  require 'zip'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class BooleanParser
3
4
 
@@ -8,4 +9,4 @@ module Saxlsx
8
9
  end
9
10
 
10
11
  end
11
- end
12
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class ColumnNameGenerator
3
4
  FIRST = 'A'
@@ -14,4 +15,4 @@ module Saxlsx
14
15
  end
15
16
  end
16
17
  end
17
- end
18
+ end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class FileSystem
4
+ IO_METHODS = [:tell, :seek, :read, :close]
3
5
 
4
6
  def self.open(filename)
5
7
  begin
@@ -11,11 +13,16 @@ module Saxlsx
11
13
  end
12
14
 
13
15
  def initialize(filename)
14
- @zip = Zip::File.open filename
16
+ if IO_METHODS.map { |method| filename.respond_to?(method) }.all?
17
+ @zip = Zip::File.open_buffer filename
18
+ @io = true
19
+ else
20
+ @zip = Zip::File.open filename
21
+ end
15
22
  end
16
23
 
17
24
  def close
18
- @zip.close
25
+ @zip.close unless @io
19
26
  end
20
27
 
21
28
  def workbook
@@ -36,4 +43,4 @@ module Saxlsx
36
43
  end
37
44
 
38
45
  end
39
- end
46
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class RowsCollection
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class RowsCollectionParser < Ox::Sax
3
4
  SECONDS_IN_DAY = 86400
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class SaxParser
3
4
 
@@ -8,4 +9,4 @@ module Saxlsx
8
9
  end
9
10
 
10
11
  end
11
- end
12
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class SharedStringCollection
3
4
 
@@ -12,4 +13,4 @@ module Saxlsx
12
13
  end
13
14
 
14
15
  end
15
- end
16
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class SharedStringCollectionParser < Ox::Sax
3
4
 
@@ -26,8 +27,8 @@ module Saxlsx
26
27
  end
27
28
 
28
29
  def text(value)
29
- @current_string << CGI.unescapeHTML(value) if @current_string
30
+ @current_string = CGI.unescapeHTML(value) if @current_string
30
31
  end
31
32
 
32
33
  end
33
- end
34
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class Sheet
3
4
 
@@ -24,4 +25,4 @@ module Saxlsx
24
25
  end
25
26
 
26
27
  end
27
- end
28
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class SheetCollection
3
4
 
@@ -13,4 +14,4 @@ module Saxlsx
13
14
  end
14
15
 
15
16
  end
16
- end
17
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class SheetCollectionParser < Ox::Sax
3
4
 
@@ -55,4 +56,4 @@ module Saxlsx
55
56
  end
56
57
 
57
58
  end
58
- end
59
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class StyleCollection
3
4
 
@@ -12,4 +13,4 @@ module Saxlsx
12
13
  end
13
14
 
14
15
  end
15
- end
16
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class StyleCollectionParser < Ox::Sax
3
4
  def self.parse(file_system, &block)
@@ -49,4 +50,4 @@ module Saxlsx
49
50
  end
50
51
  end
51
52
  end
52
- end
53
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
- VERSION = '1.6.1'
3
+ VERSION = '1.7.0'
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Saxlsx
2
3
  class Workbook
3
4
  DATE_SYSTEM_1900 = DateTime.new(1899, 12, 30)
@@ -11,7 +12,7 @@ module Saxlsx
11
12
  workbook = self.new(*args)
12
13
  yield workbook
13
14
  ensure
14
- workbook.close
15
+ workbook.close if workbook
15
16
  end
16
17
  end
17
18
 
@@ -50,4 +51,4 @@ module Saxlsx
50
51
  end
51
52
 
52
53
  end
53
- end
54
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'benchmark'
2
3
  require 'axlsx'
3
4
  require 'saxlsx'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe ColumnNameGenerator do
@@ -21,4 +22,4 @@ describe ColumnNameGenerator do
21
22
  end
22
23
  end
23
24
 
24
- end
25
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # encoding: UTF-8
2
3
  require 'spec_helper'
3
4
 
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  require 'saxlsx'
2
3
 
3
4
  include Saxlsx
4
5
 
5
6
  RSpec.configure do |config|
6
7
  config.color_enabled = true
7
- end
8
+ end
@@ -1,9 +1,17 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Workbook do
4
5
 
5
6
  let(:filename) { "#{File.dirname(__FILE__)}/data/Spec.xlsx" }
6
7
 
8
+ it 'Reads from StringIO' do
9
+ io = StringIO.new File.read(filename)
10
+ Workbook.open io do |w|
11
+ w.should have(5).sheets
12
+ end
13
+ end
14
+
7
15
  it 'Sheets count' do
8
16
  Workbook.open filename do |w|
9
17
  w.should have(5).sheets
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saxlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-11 00:00:00.000000000 Z
11
+ date: 2017-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.5.1
158
+ rubygems_version: 2.6.11
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Fast xlsx reader on top of Ox SAX parser