Sha256: a286afa5809794ad76e271e7fdda6dfe78029ef8be95e0352145b1df4ffb1db2

Contents?: true

Size: 685 Bytes

Versions: 2

Compression:

Stored size: 685 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?
      RUBY_PLATFORM =~ /darwin/ && `which growlnotify` && $? == 0
    end

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

      Thread.new { system(*command) }
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notifier-0.2.0 lib/notifier/growl.rb
notifier-0.1.5 lib/notifier/growl.rb