Sha256: f8c3ed80d3456f5c8e2055588a79e0377c0c2705c2ebfbfc01458f98056beb4e

Contents?: true

Size: 692 Bytes

Versions: 2

Compression:

Stored size: 692 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, ''),
        "--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.5.0 lib/notifier/growl.rb
notifier-0.4.1 lib/notifier/growl.rb