diff --git a/lib/guard/guard.rb b/lib/guard/guard.rb index f5059a7..f13335a 100644 --- a/lib/guard/guard.rb +++ b/lib/guard/guard.rb @@ -30,17 +30,16 @@ module Guard class Guard include Hook - attr_accessor :watchers, :options, :group, :any_return + attr_accessor :watchers, :options, :group # Initialize a Guard. # # @param [Array] watchers the Guard file watchers # @param [Hash] options the custom Guard options - # @param [Boolean] any_return allow the user to define return when using a block with a watcher # - def initialize(watchers = [], options = {}, any_return = false) + def initialize(watchers = [], options = {}) @group = options[:group] ? options.delete(:group).to_sym : :default - @watchers, @options, @any_return = watchers, options, any_return + @watchers, @options = watchers, options end # Initialize the Guard. This will copy the Guardfile template inside the Guard gem. diff --git a/lib/guard/watcher.rb b/lib/guard/watcher.rb index 59c55d6..59b0f93 100644 --- a/lib/guard/watcher.rb +++ b/lib/guard/watcher.rb @@ -46,7 +46,7 @@ module Guard if matches = watcher.match_file?(file) if watcher.action result = watcher.call_action(matches) - if guard.any_return + if guard.options[:any_return] paths << result elsif result.respond_to?(:empty?) && !result.empty? paths << Array(result) @@ -57,7 +57,7 @@ module Guard end end - guard.any_return ? paths : paths.flatten.map{ |p| p.to_s } + guard.options[:any_return] ? paths : paths.flatten.map{ |p| p.to_s } end end diff --git a/spec/guard/watcher_spec.rb b/spec/guard/watcher_spec.rb index 380a4d8..0e9eb95 100644 --- a/spec/guard/watcher_spec.rb +++ b/spec/guard/watcher_spec.rb @@ -49,7 +49,7 @@ describe Guard::Watcher do before(:all) do @guard = Guard::Guard.new @guard_any_return = Guard::Guard.new - @guard_any_return.any_return = true + @guard_any_return.options[:any_return] = true end context "with a watcher without action" do