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