Sha256: 9bdf322dd1da29d28b090b3e0d52499bd6c30c1bb4fe18429b154f3f297804dc

Contents?: true

Size: 962 Bytes

Versions: 1

Compression:

Stored size: 962 Bytes

Contents

class Growl
  COMMAND       = 'growlnotify'
  ERROR_MESSAGE = "The Growl is not installed. You can find more details here:
http://growl.info/downloads"

  def image(icon)
    @image = icon
    self
  end

  def title(text)
    @title = text
    self
  end

  def message(text)
    @message = text
    self
  end

  def priority(number)
    @priority = number
    self
  end

  def host(hostname)
    @host = hostname
    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
    end
    command
  end

  def notify!
    puts ERROR_MESSAGE unless system(to_s)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
notifiers-1.2.0 lib/notifiers/growl.rb