Sha256: 4dc7401acd4a42f5b9c1a535ce819fc5a11e9ee82bb9e05a4331543c242b7e31

Contents?: true

Size: 877 Bytes

Versions: 2

Compression:

Stored size: 877 Bytes

Contents

require 'fileutils'
require 'erb'

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__)
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

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.0 lib/notify.rb
notify-0.4.0 lib/notify.rb