From 96604060edf59bae19db25e6ba910702556ddd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Coutable?= Date: Sun, 4 Sep 2011 18:44:42 +0200 Subject: [PATCH] Clean Hook code --- lib/guard/hook.rb | 10 ++++------ spec/guard/hook_spec.rb | 15 +-------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/lib/guard/hook.rb b/lib/guard/hook.rb index 4537f7a..c2ae4c2 100644 --- a/lib/guard/hook.rb +++ b/lib/guard/hook.rb @@ -30,14 +30,12 @@ module Guard def hook(event, *args) hook_name = if event.is_a? Symbol calling_method = caller[0][/`([^']*)'/, 1] - "#{calling_method}_#{event}".to_sym + "#{calling_method}_#{event}" else - event.to_sym - end + event + end.to_sym - if ENV["GUARD_ENV"] == "development" - UI.info "\nHook :#{hook_name} executed for #{self.class}" - end + UI.debug "\nHook :#{hook_name} executed for #{self.class}" Hook.notify(self.class, hook_name, *args) end diff --git a/spec/guard/hook_spec.rb b/spec/guard/hook_spec.rb index 358cf53..af2a6ac 100644 --- a/spec/guard/hook_spec.rb +++ b/spec/guard/hook_spec.rb @@ -85,19 +85,6 @@ describe Guard::Hook do Guard::Hook.should_receive(:notify).with(guard_class, :special_sauce, 'first_arg', 'second_arg') @guard.stop end - - context "--UI message--" do - it "is sent when in development mode" do - ENV["GUARD_ENV"] = 'development' - Guard::UI.should_receive(:info) - @guard.start - ENV["GUARD_ENV"] = 'test' - end - - it "is not sent when not in development mode" do - Guard::UI.should_not_receive(:info) - @guard.start - end - end end + end