class Guard::Grunt
Constants
- DEFAULT_SIGNAL
- VERSION
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/guard/grunt.rb, line 11 def initialize(options = {}) @pid = nil @grunt_installed = grunt_installed? super end
Public Instance Methods
reload()
click to toggle source
Called on Ctrl-Z signal
# File lib/guard/grunt.rb, line 50 def reload UI.info 'Restarting grunt...' restart end
restart()
click to toggle source
# File lib/guard/grunt.rb, line 60 def restart stop start end
run_on_modifications(_paths)
click to toggle source
Called on file(s) modifications
# File lib/guard/grunt.rb, line 56 def run_on_modifications(_paths) restart end
start()
click to toggle source
# File lib/guard/grunt.rb, line 17 def start return unless @grunt_installed stop UI.info 'Starting grunt...' UI.info cmd @pid = spawn(env, cmd) end
stop()
click to toggle source
# File lib/guard/grunt.rb, line 27 def stop if @pid UI.info 'Stopping grunt...' UI.info 'Stopped process grunt' ::Process.kill DEFAULT_SIGNAL, @pid begin Timeout.timeout(15) do ::Process.wait @pid end rescue Timeout::Error UI.info 'Sending SIGKILL to grunt, as it\'s taking too long to shutdown.' ::Process.kill :KILL, @pid ::Process.wait @pid end UI.info 'Stopped process guard' end rescue Errno::ESRCH UI.info 'Guard::Grunt lost the Grunt subprocess!' ensure @pid = nil end
Private Instance Methods
cmd()
click to toggle source
# File lib/guard/grunt.rb, line 67 def cmd 'grunt watch' end
env()
click to toggle source
# File lib/guard/grunt.rb, line 71 def env {} end
grunt_installed?()
click to toggle source
# File lib/guard/grunt.rb, line 75 def grunt_installed? if find_executable 'grunt' true else UI.error 'Please install grunt, http://gruntjs.com/getting-started!' false end end