Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Roo deprecated roo method

Tags:

ruby

xls

roo-gem

Using roo gem on Windows with the following code:

require 'roo'
require 'roo-xls'

workbook = Roo::Excel.new 'test.xls'

I get message to STDOUT

[DEPRECATION] extend Roo::Tempdir and use its .make_tempdir instead

The code works fine after that, I am able to do everyting I want. However, I want to get rid of this message (without making a new class or anything like that, it's just opening a file... right?). How do I do that?

like image 483
Leśny Rumcajs Avatar asked Jul 12 '26 15:07

Leśny Rumcajs


1 Answers

The correct fix would be to not use the deprecated method and instead use the recommended one. However, in this case, it's not you who is using the deprecated method, it's the author of roo-xls:

make_tmpdir do |tmpdir| # …

So, the only things you can do are:

  1. file a bug report against roo-xls, preferably with a pull request fixing the issue (actually, the former was already done for you)
  2. for the time being, suppress deprecation warnings until the upstream issue is resolved; Roo uses Kernel#warn, so you can unfortunately only turn off all warnings, but something like this should work:

    original_warning_level = $VERBOSE
    $VERBOSE = nil
    
    workbook = Roo::Excel.new 'test.xls'
    
    $VERBOSE = original_warning_level
    
like image 151
Jörg W Mittag Avatar answered Jul 14 '26 05:07

Jörg W Mittag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!