So I am developing a Sinatra for both windows and linux. The problem is I'm using Thin instead of Webrick and eventmachine for windows only works with a pre-release version while linux uses the latest stable. in the gemfile you of course cannot include the same gem with different versions like so:
gem "eventmachine", "~> 1.0.0.beta.4.1", :group => :development_win
gem "eventmachine", group => :development_linux
You can do it like that:
# Windows gem "eventmachine", "~> 1.0.0.beta.4.1", :platform => [:mswin, :mingw] # C Ruby (MRI) or Rubinius, but NOT Windows gem "eventmachine", :platform => :ruby
Full list of available platforms:
ruby C Ruby (MRI) or Rubinius, but NOT Windows ruby_18 ruby AND version 1.8 ruby_19 ruby AND version 1.9 ruby_20 ruby AND version 2.0 mri Same as ruby, but not Rubinius mri_18 mri AND version 1.8 mri_19 mri AND version 1.9 mri_20 mri AND version 2.0 rbx Same as ruby, but only Rubinius (not MRI) jruby JRuby mswin Windows mingw Windows 'mingw32' platform (aka RubyInstaller) mingw_18 mingw AND version 1.8 mingw_19 mingw AND version 1.9 mingw_20 mingw AND version 2.0
You can find more information in
Gemfile(5) man page here (see 'Platforms' section).
Another approach is to use
if RUBY_PLATFORM =~ /win32/ gem "eventmachine", "~> 1.0.0.beta.4.1" else gem "eventmachine" end
I haven't seen full list of available values for
RUBY_PLATFORM but you can run
ruby -e 'puts RUBY_PLATFORM'
on both your platforms and see the difference.