If I have some coworkers that have an old version of Mac OS X that doesn't support the gem I want to use (terminal-notifier
specifically), are there dangers of putting this into the Gemfile
:
gem 'terminal-notifier'
Is there some way to say that it requires OS X 10.8 or greater? What happens if someone on < 10.8 tries to install terminal-notifier? I'm on the latest os so I can't exactly test this.
Put into gemfile the following condition:
if RUBY_PLATFORM =~ /darwin/i
version = `uname -r` =~ /^(\d+)\./ && $1.to_i
gem 'terminal-notifier' if version >= 12
end
This should work. I know that in case of macos 10.4 the uname -r
was 8.x, and of macos 10.5 the uname -r
was 9.x.
Or with call to sw_vers
app:
if RUBY_PLATFORM =~ /darwin/i
version = `sw_vers -productVersion` =~ /^10\.(\d+)/ && $1.to_i
gem 'terminal-notifier' if version >= 9
end
In case when the gem is to be planned to run with jruby you have to use rbconfig
module.
if RbConfig::CONFIG['host_os'] =~ /darwin|mac os/i
version = `sw_vers -productVersion` =~ /^10\.(\d+)/ && $1.to_i
gem 'terminal-notifier' if version >= 9
end