I've a ruby gem that has different dependencies for each OS. I have to explicitly write all of them down:
On Mac OS X:
gem install livereloa开发者_JS百科d
on Linux:
gem install rb-inotify livereload
on Windows:
gem install eventmachine-win32 win32-changenotify win32-event livereload
Can I tweak a gemspec a bit so installation instructions would look like plain gem install livereload
for every OS?
The proper way to do this is outlined here. Since the gemspec is evaluated at package time, you need to do it in a native extension. Don't worry, it's not that scary since its still just Ruby code (not compiling C or anything).
We are currently using this approach for some client tools for OpenShift (source). Then in your gemspec/Rakefile, instead of adding dependencies, you would add an extension. Note that the file needs to be named ext/mkrf_conf.rb
for this to work.
精彩评论