Revert "remove growl support completely"
This reverts commit 7f87411189
.
This commit is contained in:
parent
9710229f7c
commit
0e1564ef3b
2
Gemfile
2
Gemfile
@ -12,7 +12,7 @@ require 'rbconfig'
|
||||
|
||||
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
||||
gem 'rb-fsevent', '>= 0.4.0', :require => false
|
||||
gem 'growl_notify', :require => false
|
||||
gem 'growl', '~> 1.0.3', :require => false
|
||||
end
|
||||
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
||||
gem 'rb-inotify', '>= 0.8.5', :require => false
|
||||
|
11
README.md
11
README.md
@ -55,19 +55,24 @@ Install the rb-fsevent gem for [FSEvent](http://en.wikipedia.org/wiki/FSEvents)
|
||||
$ gem install rb-fsevent
|
||||
```
|
||||
|
||||
Install the growl_notify gem if you want notification support:
|
||||
Install either the growl_notify or the Growl gem if you want notification support:
|
||||
|
||||
``` bash
|
||||
$ gem install growl_notify
|
||||
$ # or
|
||||
$ gem install growl
|
||||
```
|
||||
|
||||
And add it to your Gemfile:
|
||||
And add them to your Gemfile:
|
||||
|
||||
``` ruby
|
||||
gem 'rb-fsevent'
|
||||
gem 'growl_notify'
|
||||
gem 'growl'
|
||||
```
|
||||
|
||||
growl_notify uses AppleScript, the suggested method for interfacing with Growl,
|
||||
rather than the `growlnotify` command to display messages.
|
||||
|
||||
### On Linux
|
||||
|
||||
Install the rb-inotify gem for [inotify](http://en.wikipedia.org/wiki/Inotify) support:
|
||||
|
@ -47,10 +47,18 @@ module Guard
|
||||
def self.notify_mac(title, message, image, options)
|
||||
require_growl # need for guard-rspec formatter that is called out of guard scope
|
||||
|
||||
options = { :description => message, :title => title, :icon => image_path(image), :application_name => APPLICATION_NAME }.merge(options)
|
||||
options.delete(:name)
|
||||
default_options = { :title => title, :icon => image_path(image), :name => APPLICATION_NAME }
|
||||
default_options.merge!(options)
|
||||
|
||||
GrowlNotify.send_notification(options) if enabled?
|
||||
if defined?(GrowlNotify)
|
||||
default_options[:description] = message
|
||||
default_options[:application_name] = APPLICATION_NAME
|
||||
default_options.delete(:name)
|
||||
|
||||
GrowlNotify.send_notification(default_options) if enabled?
|
||||
else
|
||||
Growl.notify message, default_options.merge(options) if enabled?
|
||||
end
|
||||
end
|
||||
|
||||
def self.notify_linux(title, message, image, options)
|
||||
@ -94,6 +102,7 @@ module Guard
|
||||
end
|
||||
|
||||
def self.require_growl
|
||||
begin
|
||||
require 'growl_notify'
|
||||
|
||||
if GrowlNotify.application_name != APPLICATION_NAME
|
||||
@ -102,9 +111,12 @@ module Guard
|
||||
c.application_name = c.notifications.first
|
||||
end
|
||||
end
|
||||
rescue LoadError
|
||||
require 'growl'
|
||||
end
|
||||
rescue LoadError
|
||||
turn_off
|
||||
UI.info "Please install growl_notify gem for Mac OS X notification support and add it to your Gemfile"
|
||||
UI.info "Please install growl or growl_notify gem for Mac OS X notification support and add it to your Gemfile"
|
||||
end
|
||||
|
||||
def self.require_libnotify
|
||||
|
@ -39,9 +39,19 @@ describe Guard::Notifier do
|
||||
end
|
||||
end
|
||||
|
||||
context "without the GrowlNofity library available" do
|
||||
context "with the Growl library available" do
|
||||
it "loads the library and enables the notifications" do
|
||||
subject.should_receive(:require).with('growl_notify').and_raise LoadError
|
||||
subject.should_receive(:require).with('growl').and_return true
|
||||
subject.turn_on
|
||||
subject.should be_enabled
|
||||
end
|
||||
end
|
||||
|
||||
context "without the Growl library available" do
|
||||
it "disables the notifications" do
|
||||
subject.should_receive(:require).with('growl_notify').and_raise LoadError
|
||||
subject.should_receive(:require).with('growl').and_raise LoadError
|
||||
subject.turn_on
|
||||
subject.should_not be_enabled
|
||||
end
|
||||
@ -102,6 +112,51 @@ describe Guard::Notifier do
|
||||
subject.stub(:require_growl)
|
||||
end
|
||||
|
||||
context 'with growl gem' do
|
||||
before do
|
||||
Object.send(:remove_const, :Growl) if defined?(Growl)
|
||||
Growl = Object.new
|
||||
end
|
||||
|
||||
after do
|
||||
Object.send(:remove_const, :Growl)
|
||||
end
|
||||
|
||||
it "passes the notification to Growl" do
|
||||
Growl.should_receive(:notify).with("great",
|
||||
:title => "Guard",
|
||||
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
||||
:name => "Guard"
|
||||
)
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "don't passes the notification to Growl if library is not available" do
|
||||
Growl.should_not_receive(:notify)
|
||||
subject.should_receive(:enabled?).and_return(true, false)
|
||||
subject.notify 'great', :title => 'Guard'
|
||||
end
|
||||
|
||||
it "allows additional notification options" do
|
||||
Growl.should_receive(:notify).with("great",
|
||||
:title => "Guard",
|
||||
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
||||
:name => "Guard",
|
||||
:priority => 1
|
||||
)
|
||||
subject.notify 'great', :title => 'Guard', :priority => 1
|
||||
end
|
||||
|
||||
it "allows to overwrite a default notification option" do
|
||||
Growl.should_receive(:notify).with("great",
|
||||
:title => "Guard",
|
||||
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
||||
:name => "Guard-Cucumber"
|
||||
)
|
||||
subject.notify 'great', :title => 'Guard', :name => "Guard-Cucumber"
|
||||
end
|
||||
end
|
||||
|
||||
context 'with growl_notify gem' do
|
||||
before do
|
||||
Object.send(:remove_const, :GrowlNotify) if defined?(GrowlNotify)
|
||||
|
Loading…
Reference in New Issue
Block a user