First trial to remove Posix Signals interaction
This commit is contained in:
parent
ca4b808b86
commit
573ddf9d9d
@ -1,4 +1,4 @@
|
||||
guard 'rspec', :version => 2, :keep_failed => false, :cli => '-f doc' do
|
||||
guard 'rspec', :version => 2, :all_on_start => false, :all_after_pass => false, :keep_failed => false, :cli => '-f doc' do
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
|
@ -26,7 +26,7 @@ module Guard
|
||||
end
|
||||
|
||||
def start(options = {})
|
||||
Interactor.init_signal_traps
|
||||
# Interactor.init_signal_traps
|
||||
|
||||
setup(options)
|
||||
|
||||
@ -40,7 +40,9 @@ module Guard
|
||||
|
||||
UI.info "Guard is now watching at '#{listener.directory}'"
|
||||
guards.each { |guard| supervised_task(guard, :start) }
|
||||
listener.start
|
||||
Thread.new { listener.start }
|
||||
|
||||
Interactor.listen
|
||||
end
|
||||
|
||||
def run_on_change_for_all_guards(files)
|
||||
@ -78,7 +80,7 @@ module Guard
|
||||
yield
|
||||
rescue Interrupt
|
||||
end
|
||||
listener.start
|
||||
Thread.new { listener.start }
|
||||
end
|
||||
|
||||
def add_guard(name, watchers = [], options = {})
|
||||
|
@ -2,53 +2,77 @@ module Guard
|
||||
module Interactor
|
||||
extend self
|
||||
|
||||
def run_all
|
||||
::Guard.run do
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
|
||||
end
|
||||
end
|
||||
|
||||
def stop
|
||||
UI.info "Bye bye...", :reset => true
|
||||
::Guard.listener.stop
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
|
||||
abort
|
||||
end
|
||||
|
||||
def reload
|
||||
::Guard.run do
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
|
||||
end
|
||||
end
|
||||
|
||||
def self.init_signal_traps
|
||||
# Run all (Ctrl-\)
|
||||
if Signal.list.has_key?('QUIT')
|
||||
Signal.trap('QUIT') do
|
||||
run_all
|
||||
def listen
|
||||
return if ENV["GUARD_ENV"] == 'test'
|
||||
if entry = $stdin.readline
|
||||
entry.gsub! /\n/, ''
|
||||
case entry
|
||||
when 'quit', 'exit', 'q', 'e'
|
||||
UI.info "Bye bye...", :reset => true
|
||||
::Guard.listener.stop
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
|
||||
abort
|
||||
when 'reload', 'r', 'z'
|
||||
::Guard.run do
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
|
||||
end
|
||||
listen
|
||||
else # run_all
|
||||
::Guard.run do
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
|
||||
end
|
||||
listen
|
||||
end
|
||||
else
|
||||
UI.info "Your system doesn't support QUIT signal, so Ctrl-\\ (Run all) won't work"
|
||||
end
|
||||
|
||||
# Stop (Ctrl-C)
|
||||
if Signal.list.has_key?('INT')
|
||||
Signal.trap('INT') do
|
||||
stop
|
||||
end
|
||||
else
|
||||
UI.info "Your system doesn't support INT signal, so Ctrl-C (Stop) won't work"
|
||||
end
|
||||
|
||||
# Reload (Ctrl-Z)
|
||||
if Signal.list.has_key?('TSTP')
|
||||
Signal.trap('TSTP') do
|
||||
reload
|
||||
end
|
||||
else
|
||||
UI.info "Your system doesn't support TSTP signal, so Ctrl-Z (Reload) won't work"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# def run_all
|
||||
# ::Guard.run do
|
||||
# ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def stop
|
||||
# UI.info "Bye bye...", :reset => true
|
||||
# ::Guard.listener.stop
|
||||
# ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
|
||||
# abort
|
||||
# end
|
||||
#
|
||||
# def reload
|
||||
# ::Guard.run do
|
||||
# ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def self.init_signal_traps
|
||||
# # Run all (Ctrl-\)
|
||||
# if Signal.list.has_key?('QUIT')
|
||||
# Signal.trap('QUIT') do
|
||||
# run_all
|
||||
# end
|
||||
# else
|
||||
# UI.info "Your system doesn't support QUIT signal, so Ctrl-\\ (Run all) won't work"
|
||||
# end
|
||||
#
|
||||
# # Stop (Ctrl-C)
|
||||
# if Signal.list.has_key?('INT')
|
||||
# Signal.trap('INT') do
|
||||
# stop
|
||||
# end
|
||||
# else
|
||||
# UI.info "Your system doesn't support INT signal, so Ctrl-C (Stop) won't work"
|
||||
# end
|
||||
#
|
||||
# # Reload (Ctrl-Z)
|
||||
# if Signal.list.has_key?('TSTP')
|
||||
# Signal.trap('TSTP') do
|
||||
# reload
|
||||
# end
|
||||
# else
|
||||
# UI.info "Your system doesn't support TSTP signal, so Ctrl-Z (Reload) won't work"
|
||||
# end
|
||||
#
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
@ -55,10 +55,10 @@ describe Guard::Listener do
|
||||
it "should relativize paths to the configured directory" do
|
||||
subject.relativize_paths(@paths).should =~ %w( a a/b a.b/c.d )
|
||||
end
|
||||
|
||||
|
||||
context "when set to false" do
|
||||
subject { described_class.new('/tmp', :relativize_paths => false) }
|
||||
|
||||
|
||||
it "can be disabled" do
|
||||
subject.relativize_paths(@paths).should eql @paths
|
||||
end
|
||||
@ -128,7 +128,6 @@ describe Guard::Listener do
|
||||
end
|
||||
|
||||
describe "working directory" do
|
||||
|
||||
context "unspecified" do
|
||||
subject { described_class.new }
|
||||
it "defaults to Dir.pwd" do
|
||||
@ -158,7 +157,6 @@ describe Guard::Listener do
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user