Class: Guard::FaktoryWorker
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::FaktoryWorker
- Defined in:
- lib/guard/faktory_worker.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FaktoryWorker
constructor
Initializes a Guard plugin.
-
#reload ⇒ Object
Called when
reload|r|z + enteris pressed. -
#run_all ⇒ Object
Called when just
enteris pressed This method should be principally used for long action like running all specs/tests/... -
#run_on_additions(paths) ⇒ Object
Called on file(s) additions that the Guard plugin watches.
-
#run_on_modifications(paths) ⇒ Object
Called on file(s) modifications that the Guard plugin watches.
-
#run_on_removals(paths) ⇒ Object
Called on file(s) removals that the Guard plugin watches.
-
#start ⇒ Object
Called once when Guard starts.
-
#stop ⇒ Object
Called when
stop|quit|exit|s|q|e + enteris pressed (when Guard quits).
Constructor Details
#initialize(options = {}) ⇒ FaktoryWorker
Initializes a Guard plugin. Don't do any work here, especially as Guard plugins get initialized even if they are not in an active group!
17 18 19 20 21 22 23 |
# File 'lib/guard/faktory_worker.rb', line 17 def initialize( = {}) opts = .dup @cmd = opts.delete(:cmd) || 'bundle exec faktory-worker' super(opts) # important to call + avoid passing options Guard doesn't understand end |
Instance Method Details
#reload ⇒ Object
Called when reload|r|z + enter is pressed.
This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
61 62 63 64 |
# File 'lib/guard/faktory_worker.rb', line 61 def reload stop start end |
#run_all ⇒ Object
Called when just enter is pressed
This method should be principally used for long action like running all specs/tests/...
72 73 74 |
# File 'lib/guard/faktory_worker.rb', line 72 def run_all true # don't do anything end |
#run_on_additions(paths) ⇒ Object
Called on file(s) additions that the Guard plugin watches.
82 83 84 |
# File 'lib/guard/faktory_worker.rb', line 82 def run_on_additions(paths) reload end |
#run_on_modifications(paths) ⇒ Object
Called on file(s) modifications that the Guard plugin watches.
92 93 94 |
# File 'lib/guard/faktory_worker.rb', line 92 def run_on_modifications(paths) reload end |
#run_on_removals(paths) ⇒ Object
Called on file(s) removals that the Guard plugin watches.
102 103 104 |
# File 'lib/guard/faktory_worker.rb', line 102 def run_on_removals(paths) reload end |
#start ⇒ Object
Called once when Guard starts. Please override initialize method to init stuff.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/guard/faktory_worker.rb', line 30 def start puts "Starting faktory-worker..." # FIXME? begin @pid = spawn(@cmd) sleep 1 Process.kill(0, @pid) == 1 rescue Errno::ESRCH false end end |
#stop ⇒ Object
Called when stop|quit|exit|s|q|e + enter is pressed (when Guard quits).
48 49 50 51 52 53 |
# File 'lib/guard/faktory_worker.rb', line 48 def stop if @pid Process.kill("INT", @pid) Process.wait(@pid) end end |