Sha256: 9a9373f78a6c7ad6274737482fc07345910e94fce3689f5da4936d1055751628

Contents?: true

Size: 957 Bytes

Versions: 5

Compression:

Stored size: 957 Bytes

Contents

def mac?
  RUBY_PLATFORM =~ /darwin/i && !$osx_foundation_failed_to_load
end

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 LoadError
    $osx_foundation_failed_to_load = true
  end
end

module Rerun
  module System

    # do we have growl or not?
    def growl?
      mac? && (growlcmd != "")
    end

    def growlcmd
      `which growlnotify`.chomp
    end
    
    def app_name
      # todo: make sure this works in non-Mac and non-Unix environments
      File.expand_path(".").gsub(/^.*\//, '').capitalize
    end

    def growl(title, body, background = true)
      if growl?
        s = "#{growlcmd} -n \"#{app_name}\" -m \"#{body}\" \"#{app_name} #{title}\""
        s += " &" if background
        `#{s}`
      end
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rerun-0.5.4 lib/system.rb
rerun-0.5.2 lib/system.rb
rerun-0.5 lib/system.rb
rerun-0.5.1 lib/system.rb
rerun-0.4 lib/system.rb