2つのGemfileを使用することは悪い習慣であることに同意し、GemfileのフラグRUBY_PLATFORM
とともに定数を含む解決策を見つけました。platform
これは最もエレガントな解決策ではないかもしれませんが、私にとってはうまくいきます。
好奇心旺盛な読者のための私のコードのチャンクは次のとおりです。
group :development, :test do
# Mac OSX notifications
gem 'growl_notify' if RUBY_PLATFORM.downcase.include?("darwin")
gem 'growl' if RUBY_PLATFORM.downcase.include?("darwin")
# Gnome notifications => aka for Linux
gem 'libnotify' if RUBY_PLATFORM.downcase.include?("linux")
# Guard-spork doesn't work with windows but it's
# awesome for other Operating Systems.
gem 'guard-spork' if RUBY_PLATFORM.downcase.include?('darwin') || RUBY_PLATFORM.downcase.include?('linux')
# Windows Rubies (RubyInstaller)
platforms :mswin, :mingw do
# Windows notifications
gem 'rb-notifu'
end
end