Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I discovered this a few years ago when someone who didn't understand what semver is was trying to do a rails version upgrade for us. They were practically throwing stuff when I got there and explained that lexicographical comparison of the strings would not work. I was about to write my own class for it, but then I thought that since Bundler knew how to resolve deps we should see what it uses. The rest is history!


I use it quite a bit when I have to monkeypatch a gem to backport a fix while I wait for a release:

    raise "check if monkeypatch in #{__FILE__} is still needed" if Gem::Version.new(Rails.version) >= Gem::Version.new("8.0.0")
This will blow up immediately when the gem gets upgraded, so we can see if we still need it, instead of it laying around in wait to cause a subtle bug in the future.


> I discovered this a few years ago

Right. I think I found it on stackoverflow.

The question is: why does the official documentation not mention this, along with guides?

Answer: because documentation is something the ruby core team does not want to think about. It is using scary language after all: English. The bane of most japanese developers. Plus, it is well-documented in Japanese already ... :>


> They were practically throwing stuff when I got there and explained that lexicographical comparison of the strings would not work.

Versions numbers can go to 10!?!


Aaand 10 years later you just learned to compare versions by equality instead of being impossibly clever.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: