Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Implemented DSL for replacing ignore and filter paths globally #364

Merged
merged 2 commits into from

3 participants

@tarsolya

Please see the following pull req. for further details: guard/listen#68

@thibaudgg
Owner

Listen 0.6.0 ready to support that.

@netzpirat netzpirat merged commit c7ea75f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 51 additions and 3 deletions.
  1. +25 −3 lib/guard/dsl.rb
  2. +26 −0 spec/guard/dsl_spec.rb
View
28 lib/guard/dsl.rb
@@ -453,7 +453,7 @@ def ignore_paths(*paths)
::Guard::UI.deprecation(IGNORE_PATHS_DEPRECATION)
end
- # Ignore certain patterns paths globally.
+ # Ignore certain paths globally.
#
# @example Ignore some paths
# ignore %r{^ignored/path/}, /man/
@@ -464,10 +464,21 @@ def ignore(*regexps)
::Guard.listener = ::Guard.listener.ignore(*regexps)
end
- # Filter certain patterns paths globally.
+ # Replace ignored paths globally
+ #
+ # @example Ignore only these paths
+ # ignore! %r{^ignored/path/}, /man/
+ #
+ # @param [Regexp] regexps a pattern for ignoring paths
+ #
+ def ignore!(*regexps)
+ ::Guard.listener = ::Guard.listener.ignore!(*regexps)
+ end
+
+ # Filter certain paths globally.
#
# @example Filter some files
- # ignore /\.txt$/, /.*\.zip/
+ # filter /\.txt$/, /.*\.zip/
#
# @param [Regexp] regexps a pattern for filtering paths
#
@@ -475,6 +486,17 @@ def filter(*regexps)
::Guard.listener = ::Guard.listener.filter(*regexps)
end
+ # Replace filtered paths globally.
+ #
+ # @example Filter only these files
+ # filter! /\.txt$/, /.*\.zip/
+ #
+ # @param [Regexp] regexps a pattern for filtering paths
+ #
+ def filter!(*regexps)
+ ::Guard.listener = ::Guard.listener.filter!(*regexps)
+ end
+
# Configure the Guard logger.
#
# * Log level must be either `:debug`, `:info`, `:warn` or `:error`.
View
26 spec/guard/dsl_spec.rb
@@ -344,6 +344,19 @@ def self.disable_user_config
end
end
+ describe "#ignore!" do
+ disable_user_config
+ let(:listener) { stub }
+
+ it "replace ignored regexps in the listener" do
+ ::Guard.stub(:listener) { listener }
+ ::Guard.listener.should_receive(:ignore!).with(/^foo/,/bar/) { listener }
+ ::Guard.should_receive(:listener=).with(listener)
+
+ described_class.evaluate_guardfile(:guardfile_contents => "ignore! %r{^foo}, /bar/")
+ end
+ end
+
describe "#filter" do
disable_user_config
let(:listener) { stub }
@@ -357,6 +370,19 @@ def self.disable_user_config
end
end
+ describe "#filter!" do
+ disable_user_config
+ let(:listener) { stub }
+
+ it "replace ignored regexps in the listener" do
+ ::Guard.stub(:listener) { listener }
+ ::Guard.listener.should_receive(:filter!).with(/.txt$/, /.*.zip/) { listener }
+ ::Guard.should_receive(:listener=).with(listener)
+
+ described_class.evaluate_guardfile(:guardfile_contents => "filter! %r{.txt$}, /.*\.zip/")
+ end
+ end
+
describe "#notification" do
disable_user_config
Something went wrong with that request. Please try again.