From ad8c031c67f946d2389b84934804e0cd09351548 Mon Sep 17 00:00:00 2001 From: aspinall Date: Fri, 17 Oct 2014 08:33:24 +1000 Subject: [PATCH] Prevented exceptions on non-Mac OS X platforms Fixed the version error and also prevented the exception from being thrown on non-Mac OSX platforms. This was screwing up guard notifications on Linux in cross platform projects. --- Ruby/lib/terminal-notifier.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ruby/lib/terminal-notifier.rb b/Ruby/lib/terminal-notifier.rb index e6d2496..16f4ec0 100644 --- a/Ruby/lib/terminal-notifier.rb +++ b/Ruby/lib/terminal-notifier.rb @@ -6,7 +6,7 @@ module TerminalNotifier class UnsupportedPlatformError < StandardError; end # Returns wether or not the current platform is Mac OS X 10.8, or higher. def self.available? - @available ||= Gem::Version.new(version) > Gem::Version.new('10.8') + @available ||= (/darwin/ =~ RUBY_PLATFORM) && Gem::Version.new(version) > Gem::Version.new('10.8') end def self.version @@ -25,7 +25,7 @@ def self.execute(verbose, options) end result else - raise UnsupportedPlatformError, "terminal-notifier is only supported on Mac OS X 10.8, or higher." + STDERR.print "terminal-notifier is only supported on Mac OS X 10.8, or higher." end end