lib/system.rb in alexch-rerun-0.2.1 vs lib/system.rb in alexch-rerun-0.3
- old
+ new
@@ -1,24 +1,32 @@
+def mac?
+ RUBY_PLATFORM =~ /darwin/i && !$osx_foundation_failed_to_load
+end
-# are we on OSX or not?
-begin
- require 'osx/foundation'
- OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
- $osx = true
-rescue MissingSourceFile
- # this is to not fail when running on a non-Mac
+def windows?
+ RUBY_PLATFORM =~ /mswin/i
end
+def linux?
+ RUBY_PLATFORM =~ /linux/i
+end
+
+if mac?
+ begin
+ require 'osx/foundation'
+ OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
+ rescue
+ $osx_foundation_failed_to_load = true
+ end
+end
+
module Rerun
module System
- def osx?
- $osx
- end
-
+
# do we have growl or not?
- def has_growl?
- growlcmd != ""
+ def growl?
+ mac? && (growlcmd != "")
end
def growlcmd
`which growlnotify`.chomp
end
@@ -27,12 +35,14 @@
# todo: make sure this works in non-Mac and non-Unix environments
File.expand_path(".").gsub(/^.*\//, '').capitalize
end
def growl(title, body, background = true)
- s = "#{growlcmd} -n \"#{app_name}\" -m \"#{body}\" \"#{app_name} #{title}\""
- s += " &" if background
- `#{s}`
+ if growl?
+ s = "#{growlcmd} -n \"#{app_name}\" -m \"#{body}\" \"#{app_name} #{title}\""
+ s += " &" if background
+ `#{s}`
+ end
end
end
end