1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
require 'fileutils'
require 'erb'
require 'notify/version'
module Notify
def self.which(prog, path=ENV['PATH'])
if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin|cygwin/
path.split(File::PATH_SEPARATOR).each {|dir|
f = File.join(dir,prog+".exe")
return f if File.executable?(File.join(f)) && !File.directory?(f)
}
nil
else
return system("which #{prog} > /dev/null 2>&1")
end
end
def self.html_escape(text)
ERB::Util.html_escape(text)
end
end
dir = File.dirname(__FILE__)
begin
if ENV['NOTIFY']
require File.join(dir, "notify/#{ENV['NOTIFY']}")
else
Dir[File.join(dir, "notify/*.rb")].each do |filename|
break if Notify.methods.include?(:notify)
require filename
end
end
rescue LoadError
# A safeguard against bad libraries or edge-case errors.
puts "Notify can't find the library specified."
end
module Notify
unless methods.include?(:notify)
def self.notify(title, message, options = {})
puts "#{title}: #{message}"
end
end
end
|