Skip to content

Commit 80146fa

Browse files
authored
Merge pull request #629 from jukra/rubyzip3
Add support for rubyzip 3.x
2 parents b63f0bc + d9e83d6 commit 80146fa

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
- Add changelog link to gemspec [605](https://github.com/roo-rb/roo/pull/605)
77
- Upgraded rack via usage of rackup
88
- Resolve deprecation warnings about uri DEFAULT_PARSER
9+
- Add support for rubyzip 3.x [629](https://github.com/roo-rb/roo/pull/629)
910

1011
### Removed
1112
- Support for ruby 2.7, 3.0
13+
- Support for rubyzip < 3.x
1214

1315
## [2.10.1] 2024-01-17
1416

lib/roo/excelx.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def extract_worksheet_ids(entries, path)
333333
wb = entries.find { |e| e.name[/workbook.xml$/] }
334334
fail ArgumentError 'missing required workbook file' if wb.nil?
335335

336-
wb.extract(path)
336+
wb.extract(File.basename(path), destination_directory: File.dirname(path))
337337
workbook_doc = Roo::Utils.load_xml(path).remove_namespaces!
338338
workbook_doc.xpath('//sheet').map { |s| s['id'] }
339339
end
@@ -357,7 +357,7 @@ def extract_worksheet_rels(entries, path)
357357
wb_rels = entries.find { |e| e.name[/workbook.xml.rels$/] }
358358
fail ArgumentError 'missing required workbook file' if wb_rels.nil?
359359

360-
wb_rels.extract(path)
360+
wb_rels.extract(File.basename(path), destination_directory: File.dirname(path))
361361
rels_doc = Roo::Utils.load_xml(path).remove_namespaces!
362362

363363
relationships = rels_doc.xpath('//Relationship').select do |relationship|
@@ -378,7 +378,7 @@ def extract_sheets_in_order(entries, sheet_ids, sheets, tmpdir)
378378
path = "#{tmpdir}/roo_sheet#{i + 1}"
379379
sheet_files << path
380380
@sheet_files << path
381-
entry.extract(path)
381+
entry.extract(File.basename(path), destination_directory: File.dirname(path))
382382
end
383383
end
384384

@@ -387,7 +387,7 @@ def extract_images(entries, tmpdir)
387387
img_entries.each do |entry|
388388
path = "#{@tmpdir}/roo#{entry.name.gsub(/xl\/|\//, "_")}"
389389
image_files << path
390-
entry.extract(path)
390+
entry.extract(File.basename(path), destination_directory: File.dirname(path))
391391
end
392392
end
393393

@@ -402,7 +402,7 @@ def process_zipfile(zipfilename_or_stream)
402402
zip_file.read_from_stream zipfilename_or_stream
403403
end
404404

405-
process_zipfile_entries zip_file.to_a.sort_by(&:name)
405+
process_zipfile_entries zip_file.entries.sort_by(&:name)
406406
end
407407

408408
def process_zipfile_entries(entries)
@@ -462,7 +462,7 @@ def process_zipfile_entries(entries)
462462
image_rels[nr - 1] = "#{@tmpdir}/roo_image_rels#{nr}"
463463
end
464464

465-
entry.extract(path) if path
465+
entry.extract(File.basename(path), destination_directory: File.dirname(path)) if path
466466
end
467467
end
468468

lib/roo/open_office.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def open_oo_file(options)
5959
fail ArgumentError, ERROR_MISSING_CONTENT_XML unless content_entry
6060

6161
roo_content_xml_path = ::File.join(@tmpdir, 'roo_content.xml')
62-
content_entry.extract(roo_content_xml_path)
62+
content_entry.extract('roo_content.xml', destination_directory: @tmpdir)
6363
decrypt_if_necessary(zip_file, content_entry, roo_content_xml_path, options)
6464
end
6565
end
@@ -234,7 +234,7 @@ def decrypt_if_necessary(
234234

235235
if (manifest_entry = zip_file.glob('META-INF/manifest.xml').first)
236236
roo_manifest_xml_path = File.join(@tmpdir, 'roo_manifest.xml')
237-
manifest_entry.extract(roo_manifest_xml_path)
237+
manifest_entry.extract('roo_manifest.xml', destination_directory: @tmpdir)
238238
manifest = ::Roo::Utils.load_xml(roo_manifest_xml_path)
239239

240240
# XPath search for manifest:encryption-data only for the content.xml

roo.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
2626
end
2727

2828
spec.add_dependency 'nokogiri', '~> 1'
29-
spec.add_dependency 'rubyzip', '>= 1.3.0', '< 3.0.0'
29+
spec.add_dependency 'rubyzip', '>= 3.0.0', '< 4.0.0'
3030

3131
spec.add_development_dependency 'rake'
3232
spec.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'

0 commit comments

Comments
 (0)