lib/roo/excel.rb in roo-0.9.2 vs lib/roo/excel.rb in roo-0.9.3

- old
+ new

@@ -29,22 +29,25 @@ filename = unzip(filename) if packed and packed == :zip if File.extname(filename) != ".xls" warn "are you sure, this is an excel file?" end @filename = filename - unless File.file?(@filename) - raise IOError, "file #{@filename} does not exist" - end - @workbook = Spreadsheet::ParseExcel.parse(filename) - @default_sheet = nil - # no need to set default_sheet if there is only one sheet in the document - if self.sheets.size == 1 - @default_sheet = self.sheets.first - end - # @first_row = @last_row = @first_column = @last_column = nil - #if ENV["roo_local"] != "thomas-p" - FileUtils::rm_r(@tmpdir) + begin + unless File.file?(@filename) + raise IOError, "file #{@filename} does not exist" + end + @workbook = Spreadsheet::ParseExcel.parse(filename) + @default_sheet = nil + # no need to set default_sheet if there is only one sheet in the document + if self.sheets.size == 1 + @default_sheet = self.sheets.first + end + # @first_row = @last_row = @first_column = @last_column = nil + #if ENV["roo_local"] != "thomas-p" + ensure + FileUtils::rm_r(@tmpdir) #end + end @first_row = Hash.new @last_row = Hash.new @first_column = Hash.new @last_column = Hash.new @cells_read = Hash.new