diff --git a/lib/roo/excelx.rb b/lib/roo/excelx.rb index 080ee9ac..e0e73312 100644 --- a/lib/roo/excelx.rb +++ b/lib/roo/excelx.rb @@ -259,7 +259,7 @@ def initialize(filename, options = {}) file_type_check(filename,'.xlsx','an Excel-xlsx', file_warning, packed) - @tmpdir = make_tmpdir(filename.split('/').last, options[:tmpdir_root]) + @tmpdir = make_tmpdir(File.basename(filename), options[:tmpdir_root]) @filename = local_filename(filename, @tmpdir, packed) @comments_files = [] @rels_files = [] diff --git a/lib/roo/open_office.rb b/lib/roo/open_office.rb index 96f8e0bd..187cf4e1 100644 --- a/lib/roo/open_office.rb +++ b/lib/roo/open_office.rb @@ -13,7 +13,7 @@ def initialize(filename, options={}) @only_visible_sheets = options[:only_visible_sheets] file_type_check(filename,'.ods','an Roo::OpenOffice', file_warning, packed) - @tmpdir = make_tmpdir(filename.split('/').last, options[:tmpdir_root]) + @tmpdir = make_tmpdir(File.basename(filename), options[:tmpdir_root]) @filename = local_filename(filename, @tmpdir, packed) #TODO: @cells_read[:default] = false Zip::File.open(@filename) do |zip_file| diff --git a/spec/lib/roo/excelx_spec.rb b/spec/lib/roo/excelx_spec.rb index 15c153fb..f4f66421 100644 --- a/spec/lib/roo/excelx_spec.rb +++ b/spec/lib/roo/excelx_spec.rb @@ -36,6 +36,15 @@ expect(Roo::Excelx.new(path, cell_max: 100)).to be_a(Roo::Excelx) end end + + context 'file path is a Pathname' do + let(:path) { Pathname.new('test/files/file_item_error.xlsx') } + + it 'creates an instance' do + expect(subject).to be_a(Roo::Excelx) + end + end + end describe '#cell' do diff --git a/spec/lib/roo/openoffice_spec.rb b/spec/lib/roo/openoffice_spec.rb index e8423257..a3633508 100644 --- a/spec/lib/roo/openoffice_spec.rb +++ b/spec/lib/roo/openoffice_spec.rb @@ -9,6 +9,17 @@ it 'creates an instance' do expect(subject).to be_a(Roo::OpenOffice) end + + context 'file path is a Pathname' do + subject do + Roo::OpenOffice.new(Pathname.new('test/files/numbers1.ods')) + end + + it 'creates an instance' do + expect(subject).to be_a(Roo::OpenOffice) + end + end + end # OpenOffice is an alias of LibreOffice. See libreoffice_spec.