Class: Kodiak::Notification
- Inherits:
-
Object
- Object
- Kodiak::Notification
- Defined in:
- lib/kodiak/notification.rb
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
-
#default_notifications ⇒ Object
Returns the value of attribute default_notifications.
-
#growl ⇒ Object
Returns the value of attribute growl.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#message ⇒ Object
Returns the value of attribute message.
-
#notifications ⇒ Object
Returns the value of attribute notifications.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #console_notify ⇒ Object
-
#growl_notify ⇒ Object
trigger a growl notification.
-
#growl_register ⇒ Object
register Kodiak as an application with Growl.
-
#initialize(message, type = "message") ⇒ Notification
constructor
A new instance of Notification.
Constructor Details
#initialize(message, type = "message") ⇒ Notification
Returns a new instance of Notification.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kodiak/notification.rb', line 10 def initialize(, type = "message") @message = @type = type console_notify if Config::CONFIG['target_os'] =~ /darwin/i @growl = Appscript.app("GrowlHelperApp"); if @growl.is_running? growl_register growl_notify end end end |
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
8 9 10 |
# File 'lib/kodiak/notification.rb', line 8 def application @application end |
#default_notifications ⇒ Object
Returns the value of attribute default_notifications.
8 9 10 |
# File 'lib/kodiak/notification.rb', line 8 def default_notifications @default_notifications end |
#growl ⇒ Object
Returns the value of attribute growl.
8 9 10 |
# File 'lib/kodiak/notification.rb', line 8 def growl @growl end |
#icon ⇒ Object
Returns the value of attribute icon.
8 9 10 |
# File 'lib/kodiak/notification.rb', line 8 def icon @icon end |
#message ⇒ Object
Returns the value of attribute message.
8 9 10 |
# File 'lib/kodiak/notification.rb', line 8 def @message end |
#notifications ⇒ Object
Returns the value of attribute notifications.
8 9 10 |
# File 'lib/kodiak/notification.rb', line 8 def notifications @notifications end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/kodiak/notification.rb', line 8 def type @type end |
Instance Method Details
#console_notify ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kodiak/notification.rb', line 27 def console_notify case @type when "success" print @message.green when "warning" print @message.yellow when "failure" print @message.red else print @message.white end end |
#growl_notify ⇒ Object
trigger a growl notification
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kodiak/notification.rb', line 42 def growl_notify = { :title => @application, :description => @message.gsub(/[\n]+/, ""), :application_name => @application, :image_from_location => @icon, :sticky => false, :priority => 0, :with_name => notifications.first } @growl.notify end |
#growl_register ⇒ Object
register Kodiak as an application with Growl
55 56 57 58 59 60 61 |
# File 'lib/kodiak/notification.rb', line 55 def growl_register @application = Kodiak::APP_NAME @icon = "#{Kodiak::CONFIG_PATH}/#{Kodiak::CONFIG_ICON}" @default_notifications = ["Kodiak Success"] @notifications = ["Kodiak Success", "Kodiak Failure"] @growl.register(:as_application => @application, :all_notifications => @notifications, :default_notifications => @default_notifications) end |