diff --git a/CHANGELOG.md b/CHANGELOG.md index a862ede1..23ecc581 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,11 @@ - Add changelog link to gemspec [605](https://github.com/roo-rb/roo/pull/605) - Upgraded rack via usage of rackup - Resolve deprecation warnings about uri DEFAULT_PARSER +- Add support for rubyzip 3.x [629](https://github.com/roo-rb/roo/pull/629) ### Removed - Support for ruby 2.7, 3.0 +- Support for rubyzip < 3.x ## [2.10.1] 2024-01-17 diff --git a/lib/roo/excelx.rb b/lib/roo/excelx.rb index 91ebc1e0..14a6b4f4 100755 --- a/lib/roo/excelx.rb +++ b/lib/roo/excelx.rb @@ -333,7 +333,7 @@ def extract_worksheet_ids(entries, path) wb = entries.find { |e| e.name[/workbook.xml$/] } fail ArgumentError 'missing required workbook file' if wb.nil? - wb.extract(path) + wb.extract(File.basename(path), destination_directory: File.dirname(path)) workbook_doc = Roo::Utils.load_xml(path).remove_namespaces! workbook_doc.xpath('//sheet').map { |s| s['id'] } end @@ -357,7 +357,7 @@ def extract_worksheet_rels(entries, path) wb_rels = entries.find { |e| e.name[/workbook.xml.rels$/] } fail ArgumentError 'missing required workbook file' if wb_rels.nil? - wb_rels.extract(path) + wb_rels.extract(File.basename(path), destination_directory: File.dirname(path)) rels_doc = Roo::Utils.load_xml(path).remove_namespaces! relationships = rels_doc.xpath('//Relationship').select do |relationship| @@ -378,7 +378,7 @@ def extract_sheets_in_order(entries, sheet_ids, sheets, tmpdir) path = "#{tmpdir}/roo_sheet#{i + 1}" sheet_files << path @sheet_files << path - entry.extract(path) + entry.extract(File.basename(path), destination_directory: File.dirname(path)) end end @@ -387,7 +387,7 @@ def extract_images(entries, tmpdir) img_entries.each do |entry| path = "#{@tmpdir}/roo#{entry.name.gsub(/xl\/|\//, "_")}" image_files << path - entry.extract(path) + entry.extract(File.basename(path), destination_directory: File.dirname(path)) end end @@ -402,7 +402,7 @@ def process_zipfile(zipfilename_or_stream) zip_file.read_from_stream zipfilename_or_stream end - process_zipfile_entries zip_file.to_a.sort_by(&:name) + process_zipfile_entries zip_file.entries.sort_by(&:name) end def process_zipfile_entries(entries) @@ -462,7 +462,7 @@ def process_zipfile_entries(entries) image_rels[nr - 1] = "#{@tmpdir}/roo_image_rels#{nr}" end - entry.extract(path) if path + entry.extract(File.basename(path), destination_directory: File.dirname(path)) if path end end diff --git a/lib/roo/open_office.rb b/lib/roo/open_office.rb index 542c5b42..f7a81391 100644 --- a/lib/roo/open_office.rb +++ b/lib/roo/open_office.rb @@ -59,7 +59,7 @@ def open_oo_file(options) fail ArgumentError, ERROR_MISSING_CONTENT_XML unless content_entry roo_content_xml_path = ::File.join(@tmpdir, 'roo_content.xml') - content_entry.extract(roo_content_xml_path) + content_entry.extract('roo_content.xml', destination_directory: @tmpdir) decrypt_if_necessary(zip_file, content_entry, roo_content_xml_path, options) end end @@ -234,7 +234,7 @@ def decrypt_if_necessary( if (manifest_entry = zip_file.glob('META-INF/manifest.xml').first) roo_manifest_xml_path = File.join(@tmpdir, 'roo_manifest.xml') - manifest_entry.extract(roo_manifest_xml_path) + manifest_entry.extract('roo_manifest.xml', destination_directory: @tmpdir) manifest = ::Roo::Utils.load_xml(roo_manifest_xml_path) # XPath search for manifest:encryption-data only for the content.xml diff --git a/roo.gemspec b/roo.gemspec index c47e3b4e..a733460b 100644 --- a/roo.gemspec +++ b/roo.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |spec| end spec.add_dependency 'nokogiri', '~> 1' - spec.add_dependency 'rubyzip', '>= 1.3.0', '< 3.0.0' + spec.add_dependency 'rubyzip', '>= 3.0.0', '< 4.0.0' spec.add_development_dependency 'rake' spec.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'