Sha256: d07ad6041f47430b023f38ac5b97ef476e4e8cd8ae54faff8a973ad01866b42c
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
require 'growlnotifier/growl_helpers' class Kicker module Growl #:nodoc: NOTIFICATIONS = { :change => 'Change occured', :succeeded => 'Command succeeded', :failed => 'Command failed' } DEFAULT_CALLBACK = lambda do OSX::NSWorkspace.sharedWorkspace.launchApplication('Terminal') end class << self include ::Growl attr_accessor :use, :command Growl.use = true Growl.command = nil def use? @use end def notifications NOTIFICATIONS end def start! ::Growl::Notifier.sharedInstance.register('Kicker', NOTIFICATIONS.values) end def change_occured(status) growl(notifications[:change], 'Kicker: Executing', status.call(:growl) || status.command) end def command_callback lambda { system(command) } if command end def result(status) status.success? ? succeeded(status) : failed(status) end def succeeded(status) callback = command_callback || DEFAULT_CALLBACK body = status.call(:growl) || (Kicker.silent? ? '' : status.output) growl(notifications[:succeeded], "Kicker: Success", body, &callback) end 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
kicker-2.3.0 | lib/kicker/growl.rb |
kicker-2.2.3 | lib/kicker/growl.rb |
kicker-2.2.2 | lib/kicker/growl.rb |
kicker-2.2.1 | lib/kicker/growl.rb |
kicker-2.2.0 | lib/kicker/growl.rb |