roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.78k stars 501 forks source link

Fix internal use of deprecated `Excelx::Cell.new` #564

Open cgunther opened 2 years ago

cgunther commented 2 years ago

Calling Excelx#set internally called Excelx::Cell.new, which is deprecated in favor of Excelx::Cell.create_cell.

I tried using the recommended Excelx::Cell.create_cell, however it expects a type as the first argument. #set tries to infer the type via cell_type_by_value, however it only returns :float or :string, but Excelx::Cell.cell_class doesn't support :float.

Even if I add :float to map to Cell::Number, then there's a dilemma because Excelx::Cell.create_cell passes all the arguments except the first onto the specific cell class, but the arity of Cell::String is 5 whereas the arity of Cell::Number is 6, meaning Excelx#set would need to initialize each cell class individually to pass the appropriate arguments.

Therefore I landed on simply using Cell::Base. It's probably not the most accurate, but given persisting the spreadsheet isn't an option, the uses for Excelx#set should be minimal. In my case, I simply use it in testing to avoid creating new files for every possible scenario, opting to manually set various cells to triggered assorted scenarios.

Fixes #529.

gee-forr commented 1 year ago

Is there any chance this PR will get merged and released? Our logs are absolutely spammed by this warning. Alternatively, is there a way we can get it to display only once instead of every time it's called?

gee-forr commented 9 months ago

Hey all - I know you're all really busy, but is there any chance of merging this in and getting a fresh version of this gem released to rubygems?