diff --git a/README.md b/README.md index ea287db..8157f5a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/creek.gemspec b/creek.gemspec index 7ad309f..316b1d6 100644 --- a/creek.gemspec +++ b/creek.gemspec @@ -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 diff --git a/lib/creek/book.rb b/lib/creek/book.rb index 613cac6..33b9509 100644 --- a/lib/creek/book.rb +++ b/lib/creek/book.rb @@ -1,7 +1,6 @@ require 'zip/filesystem' require 'nokogiri' require 'date' -require 'http' module Creek @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 13f918c..d71b707 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ require 'creek' require 'pry' +require 'time' diff --git a/spec/test_spec.rb b/spec/test_spec.rb index 2ba1ebb..3e17daf 100644 --- a/spec/test_spec.rb +++ b/spec/test_spec.rb @@ -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}]