Sha256: f2eec6b0dbd7905b6ea9c9e98eb2f0f01fa0c3eb300ff530ff76738a2eda468e

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 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/ && `ps -Al | grep GrowlHelper` && `which growlnotify` && $? == 0
    end

    def notify(options)
      register
      command = %W[
        growlnotify
        --name=test_notifier
        --image='#{options[:image]}'
        --priority=2
        --message='#{options[:message]}'
        '#{options[:title]}'
      ].join(" ")

      Thread.new { `#{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.1.3 lib/notifier/growl.rb
notifier-0.1.2 lib/notifier/growl.rb