Module: Rerun::System

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

Instance Method Summary collapse

Instance Method Details

#app_nameObject



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

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



39
40
41
42
43
44
45
46
# File 'lib/rerun/system.rb', line 39

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)


17
18
19
# File 'lib/rerun/system.rb', line 17

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

#growlcmdObject



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

def growlcmd
  growlnotify = `which growlnotify`.chomp
  # todo: check version of growlnotify and warn if it's too old
  growlnotify
end

#iconObject



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

def icon
  here = File.expand_path(File.dirname(__FILE__))
  icondir = File.expand_path("#{here}/../../icons")
  rails_sig_file = File.expand_path(".")+"/config/boot.rb"
  "#{icondir}/rails_red_sml.png" if File.exists? rails_sig_file
end

#linux?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rerun/system.rb', line 12

def linux?
   RUBY_PLATFORM =~ /linux/i
end

#mac?Boolean

Returns:

  • (Boolean)


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

def mac?
  RUBY_PLATFORM =~ /darwin/i
end

#windows?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/rerun/system.rb', line 8

def windows?
   RUBY_PLATFORM =~ /mswin/i
end