Rename Guard::Dsl.revaluate_guardfile to Guard::Dsl.reevaludate_guardfile

This commit is contained in:
Rémy Coutable 2011-07-29 00:22:53 +02:00
parent 48057cb6c8
commit 1481604411
4 changed files with 7 additions and 5 deletions

View File

@ -6,6 +6,7 @@
## Improvements ## Improvements
- `Guard::Dsl.revaluate_guardfile` has been renamed to `Guard::Dsl.reevaluate_guardfile`. ([@rymai][])
- New CLI options: ([@nestegg][]) - New CLI options: ([@nestegg][])
- `watchdir`/`-w` to specify the directory in which Guard should watch for changes, - `watchdir`/`-w` to specify the directory in which Guard should watch for changes,
- `guardfile`/`-G` to specify an alternate location for the Guardfile to use. - `guardfile`/`-G` to specify an alternate location for the Guardfile to use.

View File

@ -19,18 +19,18 @@ module Guard
@options[:notify] && ENV["GUARD_NOTIFY"] != 'false' ? Notifier.turn_on : Notifier.turn_off @options[:notify] && ENV["GUARD_NOTIFY"] != 'false' ? Notifier.turn_on : Notifier.turn_off
UI.clear if @options[:clear]
self self
end end
def start(options = {}) def start(options = {})
UI.clear if options[:clear]
setup(options) setup(options)
Interactor.init_signal_traps Interactor.init_signal_traps
Dsl.evaluate_guardfile(options) Dsl.evaluate_guardfile(options)
listener.on_change do |files| listener.on_change do |files|
Dsl.revaluate_guardfile if Watcher.match_guardfile?(files) Dsl.reevaluate_guardfile if Watcher.match_guardfile?(files)
run { run_on_change_for_all_guards(files) } if Watcher.match_files?(guards, files) run { run_on_change_for_all_guards(files) } if Watcher.match_files?(guards, files)
end end

View File

@ -12,7 +12,7 @@ module Guard
UI.error "No guards found in Guardfile, please add at least one." if !::Guard.guards.nil? && ::Guard.guards.empty? UI.error "No guards found in Guardfile, please add at least one." if !::Guard.guards.nil? && ::Guard.guards.empty?
end end
def revaluate_guardfile def reevaluate_guardfile
::Guard.guards.clear ::Guard.guards.clear
Dsl.evaluate_guardfile(@@options) Dsl.evaluate_guardfile(@@options)
msg = "Guardfile has been re-evaluated." msg = "Guardfile has been re-evaluated."
@ -50,6 +50,7 @@ module Guard
@@options[:guardfile_path] = 'Inline Guardfile' @@options[:guardfile_path] = 'Inline Guardfile'
elsif @@options.has_key?(:guardfile) elsif @@options.has_key?(:guardfile)
UI.debug File.exist?(@@options[:guardfile])
if File.exist?(@@options[:guardfile]) if File.exist?(@@options[:guardfile])
read_guardfile(@@options[:guardfile]) read_guardfile(@@options[:guardfile])
UI.info "Using Guardfile at #{@@options[:guardfile]}." UI.info "Using Guardfile at #{@@options[:guardfile]}."

View File

@ -127,7 +127,7 @@ describe Guard::Dsl do
lambda { subject.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string ) }.should raise_error lambda { subject.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string ) }.should raise_error
end end
describe ".revaluate_guardfile" do describe ".reevaluate_guardfile" do
before(:each) { ::Guard::Dsl.stub!(:instance_eval_guardfile) } before(:each) { ::Guard::Dsl.stub!(:instance_eval_guardfile) }
it "resets already definded guards before calling evaluate_guardfile" do it "resets already definded guards before calling evaluate_guardfile" do
@ -135,7 +135,7 @@ describe Guard::Dsl do
subject.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string) subject.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string)
::Guard.guards.should_not be_empty ::Guard.guards.should_not be_empty
::Guard::Dsl.should_receive(:evaluate_guardfile) ::Guard::Dsl.should_receive(:evaluate_guardfile)
subject.revaluate_guardfile subject.reevaluate_guardfile
::Guard.guards.should be_empty ::Guard.guards.should be_empty
end end
end end