Sha256: 3cdf79e25c933bff6756fad348ffb43b9542ed05cf02db1e8318d27031a679c2

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notify-0.5.2 lib/notify.rb
notify-0.5.1 lib/notify.rb