Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,19 @@ Creek will most likely return nil for a cell with images if there is no other te

## Remote files

To download a remote file, use your favorite HTTP client to download to a
temporary file. Here's an example:

```ruby
remote_url = 'http://dev-builds.libreoffice.org/tmp/test.xlsx'
Creek::Book.new remote_url, remote: true
require 'http'

zipfile = Tempfile.new("foo")
zipfile.binmode
zipfile.write(HTTP.get(path).to_s)
zipfile.close
path = zipfile.path

Creek::Book.new path
```

## Contributing
Expand Down
1 change: 0 additions & 1 deletion creek.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ Gem::Specification.new do |spec|

spec.add_dependency 'nokogiri', '>= 1.7.0'
spec.add_dependency 'rubyzip', '>= 1.0.0'
spec.add_dependency 'http', '~> 4.0'
end
8 changes: 0 additions & 8 deletions lib/creek/book.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'zip/filesystem'
require 'nokogiri'
require 'date'
require 'http'

module Creek

Expand All @@ -20,13 +19,6 @@ def initialize path, options = {}
extension = File.extname(options[:original_filename] || path).downcase
raise 'Not a valid file format.' unless (['.xlsx', '.xlsm'].include? extension)
end
if options[:remote]
zipfile = Tempfile.new("file")
zipfile.binmode
zipfile.write(HTTP.get(path).to_s)
zipfile.close
path = zipfile.path
end
@files = Zip::File.open(path)
@shared_strings = SharedStrings.new(self)
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'creek'
require 'pry'
require 'time'

2 changes: 1 addition & 1 deletion spec/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
end
end

describe 'Creek parsing a file with large numbrts.' do
describe 'Creek parsing a file with large numbers.' do
before(:all) do
@creek = Creek::Book.new 'spec/fixtures/large_numbers.xlsx'
@expected_simple_rows = [{"A"=>"7.83294732E8", "B"=>"783294732", "C"=>783294732.0}]
Expand Down