Sha256: fdd84b34322f785b7e510839b2c419c539a860c2324fd331ceb18c4c21d49786

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

module Notifier
  module Growl
    extend self

    SCRIPT = File.dirname(__FILE__) + "/../../resources/register-growl.scpt"
    FILE = File.expand_path("~/.test_notifier-growl")

    def supported?
      Notifier.os?(/darwin/) && `which growlnotify` && $? == 0
    end

    def notify(options)
      register
      command = [
        "growlnotify",
        "--name", "test_notifier",
        "--image", options.fetch(:image, "").to_s,
        "--priority", "2",
        "--message", options[:message].to_s,
        options[:title].to_s
      ]

      Thread.new { system(*command) }.join
    end

    def register
      return if File.file?(FILE)
      system "osascript #{SCRIPT} > #{FILE}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
notifier-0.5.2 lib/notifier/growl.rb