Skip to content
Browse files

watcher cleaned up.

  • Loading branch information...
1 parent a7b6ebe commit b2f282f1e80576bc6bde74b95acd2310f3c1f7ea @earlonrails committed Oct 9, 2011
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/guard/watcher.rb
View
12 lib/guard/watcher.rb
@@ -6,15 +6,16 @@ module Guard
#
class Watcher
- attr_accessor :pattern, :action, :any_rtn
+ attr_accessor :pattern, :action, :any_return
# Initialize a file watcher.
#
# @param [String, Regexp] pattern the pattern to be watched by the guard
# @param [Block] action the action to execute before passing the result to the Guard
+ # @param [Boolean] any_return allow the user to define return when using a block
#
- def initialize(pattern, action = nil, any_rtn = false)
- @pattern, @action, @any_rtn = pattern, action, any_rtn
+ def initialize(pattern, action = nil, any_return = false)
+ @pattern, @action, @any_return = pattern, action, any_return
@@warning_printed ||= false
# deprecation warning
@@ -41,12 +42,11 @@ def initialize(pattern, action = nil, any_rtn = false)
# @return [Array<Object>] the matched watcher response
def self.match_files(guard, files)
guard.watchers.inject([]) do |paths, watcher|
- wa = watcher.any_rtn
files.each do |file|
if matches = watcher.match_file?(file)
if watcher.action
result = watcher.call_action(matches)
- if wa
+ if watcher.any_return
paths << result
elsif result.respond_to?(:empty?) && ! result.empty?
paths << Array(result)
@@ -57,7 +57,7 @@ def self.match_files(guard, files)
end
end
- wa ? paths : paths.flatten.map{|p| p.to_s}
+ watcher.any_return ? paths : paths.flatten.map{|p| p.to_s}
end
end

0 comments on commit b2f282f

Please sign in to comment.
Something went wrong with that request. Please try again.