lib/watchr.rb in watchr-0.5.5 vs lib/watchr.rb in watchr-0.5.6
- old
+ new
@@ -11,20 +11,27 @@
# $ watchr path/to/script
#
# See README for more details
#
module Watchr
+ begin
+ require 'rev'
+ HAVE_REV = true
+ rescue LoadError, RuntimeError
+ HAVE_REV = false
+ end
+
autoload :Script, 'watchr/script'
autoload :Controller, 'watchr/controller'
module EventHandler
autoload :Base, 'watchr/event_handlers/base'
- autoload :Unix, 'watchr/event_handlers/unix'
+ autoload :Unix, 'watchr/event_handlers/unix' if ::Watchr::HAVE_REV
autoload :Portable, 'watchr/event_handlers/portable'
end
- VERSION = '0.5.5'
+ VERSION = '0.5.6'
class << self
attr_accessor :options
attr_accessor :handler
@@ -67,13 +74,10 @@
puts "[watchr debug] #{str}" if options.debug
end
# Detect current OS and return appropriate handler.
#
- # NOTE temporarily returns Portable handler for all platforms, until
- # issue #1 is fixed
- #
# ===== Examples
#
# Config::CONFIG['host_os'] #=> 'linux-gnu'
# Watchr.handler #=> Watchr::EventHandler::Unix
#
@@ -93,13 +97,13 @@
@handler ||=
case ENV['HANDLER'] || Config::CONFIG['host_os']
when /mswin|windows|cygwin/i
Watchr::EventHandler::Portable
when /sunos|solaris|darwin|mach|osx|bsd|linux/i, 'unix'
- begin
- require 'rev'
+ if ::Watchr::HAVE_REV
Watchr::EventHandler::Unix
- rescue LoadError, RuntimeError
+ else
+ Watchr.debug "rev not found. `gem install rev` to get evented handler"
Watchr::EventHandler::Portable
end
else
Watchr::EventHandler::Portable
end