class Guard::Clockwork

Constants

DEFAULT_CLOCKFILE

Public Class Methods

new(watchers = [], options = {}) click to toggle source
Calls superclass method
# File lib/guard/clockwork.rb, line 9
def initialize(watchers = [], options = {})
  @options = options
  @pid = nil
  @clockfile = options[:clockfile] || DEFAULT_CLOCKFILE
  super
end

Public Instance Methods

reload() click to toggle source

Called on Ctrl-Z signal

# File lib/guard/clockwork.rb, line 38
def reload
  UI.info 'Restarting clockwork...'
  restart
end
restart() click to toggle source
# File lib/guard/clockwork.rb, line 53
def restart
  stop
  start
end
run_all() click to toggle source

Called on Ctrl-/ signal

# File lib/guard/clockwork.rb, line 44
def run_all
  true
end
run_on_changes(paths) click to toggle source

Called on file(s) modifications

# File lib/guard/clockwork.rb, line 49
def run_on_changes(paths)
  restart
end
start() click to toggle source
# File lib/guard/clockwork.rb, line 16
def start
  stop
  UI.info 'Starting up clockwork...'
  UI.info cmd

  @pid = spawn({}, cmd)
end
stop() click to toggle source
# File lib/guard/clockwork.rb, line 24
def stop
  if @pid
    UI.info 'Stopping clockwork...'
    ::Process.kill :INT, @pid
    ::Process.wait @pid
    UI.info 'Stopped process clockwork'
  end
rescue Errno::ESRCH
  UI.info 'Guard::Clockwork lost the subprocess!'
ensure
  @pid = nil
end

Private Instance Methods

cmd() click to toggle source
# File lib/guard/clockwork.rb, line 60
def cmd
  "bundle exec clockwork #{@clockfile}"
end