Use 'guard' instead of 'g', use parenthesis and don't explicitly return when not necessary
This commit is contained in:
parent
3116b13f1b
commit
7f39a55fdf
@ -17,7 +17,7 @@ module Guard
|
||||
@options = options
|
||||
@listener = Listener.init
|
||||
@guards = []
|
||||
return self
|
||||
self
|
||||
end
|
||||
|
||||
def start(options = {})
|
||||
@ -41,7 +41,7 @@ module Guard
|
||||
end
|
||||
|
||||
UI.info "Guard is now watching at '#{Dir.pwd}'"
|
||||
guards.each { |g| supervised_task(g, :start) }
|
||||
guards.each { |guard| supervised_task(guard, :start) }
|
||||
listener.start
|
||||
end
|
||||
end
|
||||
@ -68,9 +68,9 @@ module Guard
|
||||
guard.send(task_to_supervise, *args)
|
||||
rescue Exception
|
||||
UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{$!}")
|
||||
::Guard.guards.delete guard
|
||||
::Guard.guards.delete(guard)
|
||||
UI.info("Guard #{guard.class.name} has just been fired")
|
||||
return $!
|
||||
$!
|
||||
end
|
||||
|
||||
def locate_guard(name)
|
||||
|
@ -3,7 +3,7 @@ module Guard
|
||||
|
||||
def self.evaluate_guardfile
|
||||
guardfile = "#{Dir.pwd}/Guardfile"
|
||||
if File.exists? guardfile
|
||||
if File.exists?(guardfile)
|
||||
begin
|
||||
dsl = new
|
||||
dsl.instance_eval(File.read(guardfile.to_s), guardfile.to_s, 1)
|
||||
|
@ -14,9 +14,9 @@ module Guard
|
||||
content = File.read('Guardfile')
|
||||
guard = File.read("#{::Guard.locate_guard(name)}/lib/guard/#{name}/templates/Guardfile")
|
||||
File.open('Guardfile', 'wb') do |f|
|
||||
f.puts content
|
||||
f.puts ""
|
||||
f.puts guard
|
||||
f.puts(content)
|
||||
f.puts("")
|
||||
f.puts(guard)
|
||||
end
|
||||
::Guard::UI.info "#{name} guard added to Guardfile, feel free to edit it"
|
||||
end
|
||||
|
@ -5,14 +5,14 @@ module Guard
|
||||
# Run all (Ctrl-\)
|
||||
Signal.trap('QUIT') do
|
||||
::Guard.run do
|
||||
::Guard.guards.each { |g| ::Guard.supervised_task g, :run_all }
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
|
||||
end
|
||||
end
|
||||
|
||||
# Stop (Ctrl-C)
|
||||
Signal.trap('INT') do
|
||||
::Guard.listener.stop
|
||||
::Guard.guards.each { |g| ::Guard.supervised_task g, :stop }
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
|
||||
UI.info "Bye bye...", :reset => true
|
||||
abort("\n")
|
||||
end
|
||||
@ -20,7 +20,7 @@ module Guard
|
||||
# Reload (Ctrl-Z)
|
||||
Signal.trap('TSTP') do
|
||||
::Guard.run do
|
||||
::Guard.guards.each { |g| ::Guard.supervised_task g, :reload }
|
||||
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user