ruby-mass
ruby-mass copied to clipboard
Mass.print: "comparison of NilClass with String failed"
When I try to run Mass.print from rails console (or inside my app), it thinks for a long time and then errors with:
==================================================
Objects within [] namespace
==================================================
ArgumentError: comparison of NilClass with String failed
from /Users/gmcnaughton/.rvm/gems/ruby-1.9.3-p194/gems/ruby-mass-0.1.3/lib/mass.rb:58:in `sort'
from /Users/gmcnaughton/.rvm/gems/ruby-1.9.3-p194/gems/ruby-mass-0.1.3/lib/mass.rb:58:in `print'
from (irb):1
from /Users/gmcnaughton/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from /Users/gmcnaughton/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from /Users/gmcnaughton/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any thoughts? This happens even if Mass.print is the first thin I run in the console. Our codebase is large with a variety of gems, so I'll try to repro with a smaller set. (using ruby-mass 0.1.3)
Worked around this by changing lib/mass.rb ln 58 to:
stats.keys.sort{|a, b| [stats[b].to_i, a.to_s] <=> [stats[a].to_i, b.to_s]}.each do |key|
(note addition of .to_i and .to_s to compared values). I wasn't able to create a repro'ing test case (otherwise I'd send a pull request) but it did me get past the error.