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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: b2377d5d56234ed481fc3642c951b6d207eb45c82faa9cc263159576190da221
4
- data.tar.gz: 7552dd98f0eda1dedc73b25dac9350a592ae5ccb176380486c82c0d24898b77a
2
+ SHA1:
3
+ metadata.gz: b454dcaf4ce681693d8b8db6c022a8119f13deb7
4
+ data.tar.gz: fd1955d05f4ef0288c0aef9542ac4e8571332c81
5
5
  SHA512:
6
- metadata.gz: fe1d61dfd5c5de7c31da80dc1aaf25ba9a4d10c7ce5fe2ff0c152b1156182364af6875a24427490600b33030fb64d716b633b93b19ff69312ec6729670154bd8
7
- data.tar.gz: f6830f1b392a280eb76d1a13f9ba21094c7cf6a87807a28c8f745ca038c105b1f2290042608d897fd7e25565cea8383f1211ee1b9cc71fd283b33b9478b503a7
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.
@@ -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.3"
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.7.0'
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
@@ -1,7 +1,7 @@
1
1
  require 'zip/filesystem'
2
2
  require 'nokogiri'
3
3
  require 'date'
4
- require 'http'
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Creek
2
- VERSION = "2.4.4"
2
+ VERSION = "2.5.0"
3
3
  end
@@ -1,3 +1,7 @@
1
1
  require 'creek'
2
2
  require 'pry'
3
+ require 'time'
3
4
 
5
+ RSpec.configure do |config|
6
+ config.filter_run_excluding remote: true
7
+ end
@@ -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.4
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-03-12 00:00:00.000000000 Z
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: '1.3'
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: '1.3'
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.7.0
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.7.0
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.7.8
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.