lib/notifiers/growl.rb in notifiers-1.2.0 vs lib/notifiers/growl.rb in notifiers-1.2.1

- old
+ new

@@ -1,55 +1,47 @@ -class Growl - COMMAND = 'growlnotify' - ERROR_MESSAGE = "The Growl is not installed. You can find more details here: -http://growl.info/downloads" +module Notifiers + class Growl < Notifiers::Base + def self.installed? + darwin? and command?('growlnotify') + end - def image(icon) - @image = icon - self - end + def image(icon) + @image = icon + self + end - def title(text) - @title = text - self - end + def priority(number) + @priority = number + self + end - def message(text) - @message = text - self - end + def host(hostname) + @host = hostname + self + end - def priority(number) - @priority = number - self - end + def password(secret) + @password = secret + self + end - def host(hostname) - @host = hostname - self - end + def auth(authentication) + @auth = authentication + self + end - def password(secret) - @password = secret - self - end - - def auth(authentication) - @auth = authentication - self - end - - def to_s - command = COMMAND.clone - command << " --title '#{@title}'" if @title - command << " --message '#{@message}'" - [:image, :priority, :host, :password, :auth].each do |option| - variable = instance_variable_get("@#{option}") - command << " --#{option} #{variable}" if variable + def to_s + command = 'growlnotify' + command << " --title '#{@title}'" if @title + command << " --message '#{@message}'" + [:image, :priority, :host, :password, :auth].each do |option| + variable = instance_variable_get("@#{option}") + command << " --#{option} #{variable}" if variable + end + command end - command - end - def notify! - puts ERROR_MESSAGE unless system(to_s) + def install_instructions + 'The Growl is not installed. You can find more details here: http://growl.info/downloads' + end end end \ No newline at end of file