Module: Watchr

Defined in:
lib/watchr.rb,
lib/watchr/script.rb,
lib/watchr/controller.rb,
lib/watchr/event_handlers/em.rb,
lib/watchr/event_handlers/rev.rb,
lib/watchr/event_handlers/base.rb,
lib/watchr/event_handlers/unix.rb,
lib/watchr/event_handlers/portable.rb

Overview

Agile development tool that monitors a directory recursively, and triggers a user defined action whenever an observed file is modified. Its most typical use is continuous testing.

Usage:

# on command line, from project's root dir
$ watchr path/to/script

See README for more details

Defined Under Namespace

Modules: EventHandler Classes: Controller, Refresh, Script

Constant Summary collapse

VERSION =
'0.5.7'

Class Method Summary collapse

Class Method Details

.batchesObject



4
5
6
# File 'lib/watchr/script.rb', line 4

def batches
  @batches ||= {}
end

.debug(str) ⇒ Object

Outputs formatted debug statement to stdout, only if ::options.debug is true

Examples
Watchr.options.debug = true
Watchr.debug('im in ur codes, notifayinin u')

outputs: ā€œ[watchr debug] im in ur codes, notifayinin uā€



64
65
66
# File 'lib/watchr.rb', line 64

def debug(str)
  puts "[watchr debug] #{str}" if options.debug
end

.handlerObject

Detect current OS and return appropriate handler.

Examples
Config::CONFIG['host_os'] #=> 'linux-gnu'
Watchr.handler #=> Watchr::EventHandler::Unix

Config::CONFIG['host_os'] #=> 'cygwin'
Watchr.handler #=> Watchr::EventHandler::Portable

ENV['HANDLER'] #=> 'unix'
Watchr.handler #=> Watchr::EventHandler::Unix

ENV['HANDLER'] #=> 'portable'
Watchr.handler #=> Watchr::EventHandler::Portable
Returns
handler<Class>

handler class for current architecture



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/watchr.rb', line 87

def handler
  @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'
        Watchr::EventHandler::Unix.default
      else
        Watchr::EventHandler::Portable
    end
end

.optionsObject

Options proxy.

Currently supported options:

  • debug<Boolean> Debugging state. More verbose.

Examples
Watchr.options.debug #=> false
Watchr.options.debug = true
Returns
options<Struct>

options proxy.

ā€“ On first use, initialize the options struct and default option values.



48
49
50
51
52
53
# File 'lib/watchr.rb', line 48

def options
  @options ||= Struct.new(:debug,:once).new
  @options.debug ||= false
  @options.once.nil? and @options.once = false
  @options
end

.versionObject

backwards compatibility



29
30
31
# File 'lib/watchr.rb', line 29

def version #:nodoc:
  Watchr::VERSION
end