Module: Rerun::System

Included in:
Runner
Defined in:
lib/rerun/system.rb

Instance Method Summary collapse

Instance Method Details

#app_nameObject



39
40
41
42
# File 'lib/rerun/system.rb', line 39

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

#growl(title, body, background = true) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/rerun/system.rb', line 53

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

#growl?Boolean

do we have growl or not?

Returns:

  • (Boolean)


31
32
33
# File 'lib/rerun/system.rb', line 31

def growl?
  mac? && (growlcmd != "")
end

#growlcmdObject



35
36
37
# File 'lib/rerun/system.rb', line 35

def growlcmd
  `which growlnotify`.chomp
end

#iconObject



44
45
46
47
48
49
50
51
# File 'lib/rerun/system.rb', line 44

def icon
  libdir = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}/lib"
  $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)

  rails_sig_file = File.expand_path(".")+"/config/boot.rb"
  return "#{libdir}/../icons/rails_red_sml.png" if File.exists? rails_sig_file
  return nil
end

#linux?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rerun/system.rb', line 26

def linux?
   RUBY_PLATFORM =~ /linux/i
end

#mac?Boolean

Returns:

  • (Boolean)


4
5
6
7
# File 'lib/rerun/system.rb', line 4

def mac?
  # puts "RUBY_PLATFORM=#{RUBY_PLATFORM}"
  RUBY_PLATFORM =~ /darwin/i
end

#osx_foundation?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rerun/system.rb', line 9

def osx_foundation?
  mac? and begin
    if $osx_foundation.nil?
      require 'osx/foundation'
      OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
      $osx_foundation = true
    end
    $osx_foundation
  rescue LoadError
    $osx_foundation = false
  end
end

#windows?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rerun/system.rb', line 22

def windows?
   RUBY_PLATFORM =~ /mswin/i
end