Clean Hook code
This commit is contained in:
parent
11495687f4
commit
96604060ed
@ -30,14 +30,12 @@ module Guard
|
|||||||
def hook(event, *args)
|
def hook(event, *args)
|
||||||
hook_name = if event.is_a? Symbol
|
hook_name = if event.is_a? Symbol
|
||||||
calling_method = caller[0][/`([^']*)'/, 1]
|
calling_method = caller[0][/`([^']*)'/, 1]
|
||||||
"#{calling_method}_#{event}".to_sym
|
"#{calling_method}_#{event}"
|
||||||
else
|
else
|
||||||
event.to_sym
|
event
|
||||||
end
|
end.to_sym
|
||||||
|
|
||||||
if ENV["GUARD_ENV"] == "development"
|
UI.debug "\nHook :#{hook_name} executed for #{self.class}"
|
||||||
UI.info "\nHook :#{hook_name} executed for #{self.class}"
|
|
||||||
end
|
|
||||||
|
|
||||||
Hook.notify(self.class, hook_name, *args)
|
Hook.notify(self.class, hook_name, *args)
|
||||||
end
|
end
|
||||||
|
@ -85,19 +85,6 @@ describe Guard::Hook do
|
|||||||
Guard::Hook.should_receive(:notify).with(guard_class, :special_sauce, 'first_arg', 'second_arg')
|
Guard::Hook.should_receive(:notify).with(guard_class, :special_sauce, 'first_arg', 'second_arg')
|
||||||
@guard.stop
|
@guard.stop
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
it "is not sent when not in development mode" do
|
|
||||||
Guard::UI.should_not_receive(:info)
|
|
||||||
@guard.start
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user