creek 2.4.4 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +6 -0
- data/creek.gemspec +3 -4
- data/lib/creek/book.rb +17 -8
- data/lib/creek/drawing.rb +3 -1
- data/lib/creek/version.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- data/spec/test_spec.rb +14 -0
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b454dcaf4ce681693d8b8db6c022a8119f13deb7
|
4
|
+
data.tar.gz: fd1955d05f4ef0288c0aef9542ac4e8571332c81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d68e0282c6c4170d0097251282e7683c018563386c8961e31bb4d2e3ea65960b0871373e05233499d58d08feb5a2d57389a14e8d53e253bc6b11b2bd23e08ba9
|
7
|
+
data.tar.gz: 5451d628684257f3ffea531d8a77b7b7b306417ff1590f2047e11c9f3468a72a0d0ba333853bbbf50f0806145b4d4334629b8261663beeba70fe1069dac6681d
|
data/README.md
CHANGED
@@ -118,6 +118,12 @@ Once this is complete, you should be able to run the test suite:
|
|
118
118
|
rake
|
119
119
|
```
|
120
120
|
|
121
|
+
There are some remote tests that are excluded by default. To run those, run
|
122
|
+
|
123
|
+
```
|
124
|
+
bundle exec rspec --tag remote
|
125
|
+
```
|
126
|
+
|
121
127
|
## Bug Reporting
|
122
128
|
|
123
129
|
Please use the [Issues](https://github.com/pythonicrubyist/creek/issues) page to report bugs or suggest new enhancements.
|
data/creek.gemspec
CHANGED
@@ -20,12 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = '>= 2.0.0'
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.1.2"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3.6.0'
|
26
|
-
spec.add_development_dependency 'pry'
|
26
|
+
spec.add_development_dependency 'pry-byebug'
|
27
27
|
|
28
|
-
spec.add_dependency 'nokogiri', '>= 1.
|
28
|
+
spec.add_dependency 'nokogiri', '>= 1.10.0'
|
29
29
|
spec.add_dependency 'rubyzip', '>= 1.0.0'
|
30
|
-
spec.add_dependency 'http', '~> 4.0'
|
31
30
|
end
|
data/lib/creek/book.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'zip/filesystem'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'date'
|
4
|
-
require '
|
4
|
+
require 'open-uri'
|
5
5
|
|
6
6
|
module Creek
|
7
7
|
|
@@ -20,13 +20,7 @@ module Creek
|
|
20
20
|
extension = File.extname(options[:original_filename] || path).downcase
|
21
21
|
raise 'Not a valid file format.' unless (['.xlsx', '.xlsm'].include? extension)
|
22
22
|
end
|
23
|
-
if options[:remote]
|
24
|
-
zipfile = Tempfile.new("file")
|
25
|
-
zipfile.binmode
|
26
|
-
zipfile.write(HTTP.get(path).to_s)
|
27
|
-
zipfile.close
|
28
|
-
path = zipfile.path
|
29
|
-
end
|
23
|
+
path = download_file(path) if options[:remote]
|
30
24
|
@files = Zip::File.open(path)
|
31
25
|
@shared_strings = SharedStrings.new(self)
|
32
26
|
end
|
@@ -79,5 +73,20 @@ module Creek
|
|
79
73
|
result
|
80
74
|
end
|
81
75
|
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def download_file(url)
|
80
|
+
# OpenUri will return a StringIO if under OpenURI::Buffer::StringMax
|
81
|
+
# threshold, and a Tempfile if over.
|
82
|
+
downloaded = URI(url).open
|
83
|
+
if downloaded.is_a? StringIO
|
84
|
+
path = Tempfile.new(['creek-file', '.xlsx']).path
|
85
|
+
File.binwrite(path, downloaded.read)
|
86
|
+
path
|
87
|
+
else
|
88
|
+
downloaded.path
|
89
|
+
end
|
90
|
+
end
|
82
91
|
end
|
83
92
|
end
|
data/lib/creek/drawing.rb
CHANGED
@@ -83,7 +83,9 @@ module Creek
|
|
83
83
|
col_to_selector = 'xdr:to/xdr:col'.freeze
|
84
84
|
|
85
85
|
@drawings.xpath('//xdr:twoCellAnchor').each do |drawing|
|
86
|
-
embed = drawing.xpath(image_selector).first.attributes['embed']
|
86
|
+
# embed = drawing.xpath(image_selector).first.attributes['embed']
|
87
|
+
temp = drawing.xpath(image_selector).first
|
88
|
+
embed = temp.attributes['embed'] if temp
|
87
89
|
next if embed.nil?
|
88
90
|
|
89
91
|
rid = embed.value
|
data/lib/creek/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/test_spec.rb
CHANGED
@@ -106,6 +106,20 @@ describe 'Creek parsing a sample XLSX file' do
|
|
106
106
|
expect(@creek).not_to be_nil
|
107
107
|
end
|
108
108
|
|
109
|
+
it 'opens small remote files successfully', remote: true do
|
110
|
+
url = 'https://file-examples.com/wp-content/uploads/2017/02/file_example_XLSX_10.xlsx'
|
111
|
+
@creek = Creek::Book.new(url, remote: true)
|
112
|
+
|
113
|
+
expect(@creek.sheets[0]).to be_a Creek::Sheet
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'opens large remote files successfully', remote: true do
|
117
|
+
url = 'http://www.house.leg.state.mn.us/comm/docs/BanaianZooExample.xlsx'
|
118
|
+
@creek = Creek::Book.new(url, remote: true)
|
119
|
+
|
120
|
+
expect(@creek.sheets[0]).to be_a Creek::Sheet
|
121
|
+
end
|
122
|
+
|
109
123
|
it 'find sheets successfully.' do
|
110
124
|
expect(@creek.sheets.count).to eq(1)
|
111
125
|
sheet = @creek.sheets.first
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: creek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pythonicrubyist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.2
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.1.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.6.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
56
|
+
name: pry-byebug
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.10.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.10.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubyzip
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.0.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: http
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '4.0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '4.0'
|
111
97
|
description: A Ruby gem that streams and parses large Excel(xlsx and xlsm) files fast
|
112
98
|
and efficiently.
|
113
99
|
email:
|
@@ -176,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
162
|
version: '0'
|
177
163
|
requirements: []
|
178
164
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.5.2.3
|
180
166
|
signing_key:
|
181
167
|
specification_version: 4
|
182
168
|
summary: A Ruby gem for parsing large Excel(xlsx and xlsm) files.
|