Module: Kicker::Growl

Extended by:
Growl
Defined in:
lib/kicker/growl.rb

Overview

:nodoc:

Constant Summary collapse

NOTIFICATIONS =
{
  :change => 'Change occured',
  :succeeded => 'Command succeeded',
  :failed => 'Command failed'
}
DEFAULT_CALLBACK =
lambda do
  OSX::NSWorkspace.sharedWorkspace.launchApplication('Terminal')
end

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.commandObject

Returns the value of attribute command.



17
18
19
# File 'lib/kicker/growl.rb', line 17

def command
  @command
end

.useObject

Returns the value of attribute use.



17
18
19
# File 'lib/kicker/growl.rb', line 17

def use
  @use
end

Class Method Details

.change_occured(status) ⇒ Object



34
35
36
# File 'lib/kicker/growl.rb', line 34

def change_occured(status)
  growl(notifications[:change], 'Kicker: Executing', status.call(:growl) || status.command)
end

.command_callbackObject



38
39
40
# File 'lib/kicker/growl.rb', line 38

def command_callback
  lambda { system(command) } if command
end

.failed(status) ⇒ Object



52
53
54
55
56
# File 'lib/kicker/growl.rb', line 52

def failed(status)
  message = "Kicker: Failed (#{status.exit_code})"
  body = status.call(:growl) || (Kicker.silent? ? '' : status.output)
  growl(notifications[:failed], message, body, &DEFAULT_CALLBACK)
end

.notificationsObject



26
27
28
# File 'lib/kicker/growl.rb', line 26

def notifications
  NOTIFICATIONS
end

.result(status) ⇒ Object



42
43
44
# File 'lib/kicker/growl.rb', line 42

def result(status)
  status.success? ? succeeded(status) : failed(status)
end

.start!Object



30
31
32
# File 'lib/kicker/growl.rb', line 30

def start!
  ::Growl::Notifier.sharedInstance.register('Kicker', NOTIFICATIONS.values)
end

.succeeded(status) ⇒ Object



46
47
48
49
50
# File 'lib/kicker/growl.rb', line 46

def succeeded(status)
  callback = command_callback || DEFAULT_CALLBACK
  body = status.call(:growl) || (Kicker.silent? ? '' : status.output)
  growl(notifications[:succeeded], "Kicker: Success", body, &callback)
end

.use?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/kicker/growl.rb', line 22

def use?
  @use
end