Leśny Rumcajs Leśny Rumcajs - 1 year ago 193
Ruby Question

Roo deprecated roo method

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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download