Skip to content

Commit

Permalink
Fixes old syntax stuff and adds a better implementation of the availa…
Browse files Browse the repository at this point in the history
…ble? method.
  • Loading branch information
Wouter de Vos committed Jul 31, 2012
1 parent ac293c2 commit ef11bf1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/guard/notifiers/terminal_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ module TerminalNotifier
def self.available?(silent=false)
begin
require 'terminal-notifier'
rescue LoadError

if ::TerminalNotifier.available?
return true
else
::Guard::UI.error 'The :terminal_notifier only runs on Mac OS X 10.8 and later.' unless silent
false
end
rescue LoadError && NameError
::Guard::UI.error "Please add \"gem 'terminal_notifier'\" to your Gemfile and run Guard with \"bundle exec\"." unless silent
return false
false
end
return true if ::TerminalNotifier.available?
::Guard::UI.error 'The :terminal_notifier only runs on Mac OS X 10.8 and later.' unless silent
rescue NameError
end

# Show a system notification.
Expand Down
2 changes: 1 addition & 1 deletion spec/guard/notifiers/terminal_notifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.show(options) end
it "should call the notifier." do
::TerminalNotifier.should_receive(:notify).with(
"any message",
{:title=>"Guard Success any title"},
{:title=>"Guard Success any title"}
)
subject.notify('success', 'any title', 'any message', 'any image', { })
end
Expand Down

0 comments on commit ef11bf1

Please sign in to comment.