From d4669503b5b80c1d30f035177a2b0e4b56fc49ce Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Mon, 24 Nov 2014 02:03:43 -0800 Subject: [PATCH] Drop our Roo::ZipFile abstraction in favor of more recent dependencies. --- CHANGELOG | 1 + lib/roo/base.rb | 5 +++-- lib/roo/excelx.rb | 3 ++- lib/roo/open_office.rb | 3 ++- lib/roo/zip_file.rb | 9 --------- roo.gemspec | 2 +- 6 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 lib/roo/zip_file.rb diff --git a/CHANGELOG b/CHANGELOG index 70784a97..7486dc83 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ * enhancements * Extend Roo::Spreadsheet.open to accept Tempfiles and other arguments responding to #path. Note they require an :extension option to be declared, as the tempfile mangles the extension. #84. * Remove deprecated code. + * Remove the Roo::ZipFile abstraction. Roo now depends on rubyzip 1.0.0+ * Extract Roo::Excel and Roo::Excel2003XML to roo-xls * Extract Roo::Google to roo-google * Accept the tmpdir_root option in Roo::Excelx diff --git a/lib/roo/base.rb b/lib/roo/base.rb index eb6092ad..ae4edf2b 100644 --- a/lib/roo/base.rb +++ b/lib/roo/base.rb @@ -3,7 +3,6 @@ require 'tmpdir' require 'stringio' require 'nokogiri' -require 'roo/zip_file' require 'roo/utils' # Base class for all other types of spreadsheets @@ -634,7 +633,9 @@ def open_from_stream(stream, tmpdir) end def unzip(filename, tmpdir) - Roo::ZipFile.open(filename) do |zip| + require 'zip/filesystem' + + Zip::File.open(filename) do |zip| process_zipfile_packed(zip, tmpdir) end end diff --git a/lib/roo/excelx.rb b/lib/roo/excelx.rb index 6ede550d..cfbdd8c3 100644 --- a/lib/roo/excelx.rb +++ b/lib/roo/excelx.rb @@ -1,6 +1,7 @@ require 'date' require 'nokogiri' require 'roo/link' +require 'zip/filesystem' class Roo::Excelx < Roo::Base autoload :Workbook, 'roo/excelx/workbook' @@ -427,7 +428,7 @@ def comments(sheet=nil) # Extracts all needed files from the zip file def process_zipfile(tmpdir, zipfilename) @sheet_files = [] - Roo::ZipFile.foreach(zipfilename) do |entry| + Zip::File.foreach(zipfilename) do |entry| path = case entry.name.downcase when /workbook.xml$/ diff --git a/lib/roo/open_office.rb b/lib/roo/open_office.rb index 4089a321..32640114 100644 --- a/lib/roo/open_office.rb +++ b/lib/roo/open_office.rb @@ -1,6 +1,7 @@ require 'date' require 'nokogiri' require 'cgi' +require 'zip/filesystem' class Roo::OpenOffice < Roo::Base # initialization and opening of a spreadsheet file @@ -13,7 +14,7 @@ def initialize(filename, options={}) @tmpdir = make_tmpdir(filename.split('/').last, options[:tmpdir_root]) @filename = local_filename(filename, @tmpdir, packed) #TODO: @cells_read[:default] = false - Roo::ZipFile.open(@filename) do |zip_file| + Zip::File.open(@filename) do |zip_file| if content_entry = zip_file.glob("content.xml").first content_entry.extract(File.join(@tmpdir, 'roo_content.xml')) else diff --git a/lib/roo/zip_file.rb b/lib/roo/zip_file.rb deleted file mode 100644 index ca3c6a60..00000000 --- a/lib/roo/zip_file.rb +++ /dev/null @@ -1,9 +0,0 @@ -Roo::ZipFile = - begin - require 'zip/zipfilesystem' - Zip::ZipFile - rescue LoadError - # For rubyzip >= 1.0.0 - require 'zip/filesystem' - Zip::File - end diff --git a/roo.gemspec b/roo.gemspec index 116c00f8..ee041d57 100644 --- a/roo.gemspec +++ b/roo.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_dependency 'nokogiri' - spec.add_dependency 'rubyzip', '~> 1' + spec.add_dependency 'rubyzip', '>= 1.0.0' spec.add_development_dependency 'bundler', '>= 1.7' spec.add_development_dependency 'rake', '>= 10.0'