Skip to content

Commit

Permalink
Update GNTP notifier. (Fixes #231)
Browse files Browse the repository at this point in the history
With Growl 2.0 being released, the images are shown properly
again, but they most be binary encoded and not a url as
described in the GNTP spec. This can be achieved by using
`127.0.0.1` instead of `localhost`, and ruby_gntp will send
the image as binary.

In addition, on GNTP registration Guard send its application
icon, so we have the nice Guard logo in the Growl preferences.
  • Loading branch information
netzpirat committed Sep 20, 2012
1 parent 94623f2 commit 479d9b9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Master

- Add Guard application icon to GNTP notifier. ([@netzpirat][])
- [#324][] Allow Terminal Notifier title to be customizable. ([@mattgreen][])

## 1.3.2 - 15 August, 2012
Expand Down Expand Up @@ -667,4 +668,4 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
[@waldo]: https://github.com/waldo
[@wereHamster]: https://github.com/wereHamster
[@yannlugrin]: https://github.com/yannlugrin
[@zonque]: https://github.com/zonque
[@zonque]: https://github.com/zonque
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,39 +69,17 @@ the time, try the [Rubygems Bundler](https://github.com/mpapis/rubygems-bundler)
You can configure Guard to make use of the following system notification libraries, but it's strongly recommended
to use either Ruby GNTP, Libnotify or Notifu:

#### Growl

* Runs on Mac OS X
* Supports all [Growl](http://growl.info/) versions

The [growl](https://rubygems.org/gems/growl) gem is compatible with all versions of Growl and uses a command line tool
[growlnotify](http://growl.info/extras.php#growlnotify) that must be separately downloaded and installed. The version of
the command line tool must match your Growl version. The `growl` gem does **not** support multiple notification
channels.

You have to download the installer for `growlnotify` from the [Growl download section](http://growl.info/downloads).

To use `growl` you have to add it to your `Gemfile` and run bundler:

```ruby
group :development do
gem 'growl'
end
```

#### Ruby GNTP

**There's currently a bug in Growl that prevents displaying the icons through GNTP, see
[issue #231](https://github.com/guard/guard/issues/231). Use the growl gem until fixed.**

* Runs on Mac OS X, Linux and Windows
* Supports [Growl](http://growl.info/) version >= 1.3, [Growl for Linux](http://mattn.github.com/growl-for-linux/),
[Growl for Windows](http://www.growlforwindows.com/gfw/default.aspx) and
[Snarl](https://sites.google.com/site/snarlapp/home)

The [ruby_gntp](https://rubygems.org/gems/ruby_gntp) gem sends system notifications over the network with the
[Growl Notification Transport Protocol](http://www.growlforwindows.com/gfw/help/gntp.aspx) and supports local and
remote notifications.
remote notifications. To have the images be displayed, you have to use `127.0.0.1` instead of `localhost` in your GTNP
configuration.

Guard supports multiple notification channels for customizing each notification type. For Growl on Mac OS X you need
to have at least version 1.3 installed.
Expand All @@ -114,6 +92,26 @@ group :development do
end
```

#### Growl

* Runs on Mac OS X
* Supports all [Growl](http://growl.info/) versions

The [growl](https://rubygems.org/gems/growl) gem is compatible with all versions of Growl and uses a command line tool
[growlnotify](http://growl.info/extras.php#growlnotify) that must be separately downloaded and installed. The version of
the command line tool must match your Growl version. The `growl` gem does **not** support multiple notification
channels.

You have to download the installer for `growlnotify` from the [Growl download section](http://growl.info/downloads).

To use `growl` you have to add it to your `Gemfile` and run bundler:

```ruby
group :development do
gem 'growl'
end
```

#### Libnotify

* Runs on Linux, FreeBSD, OpenBSD and Solaris
Expand Down
Binary file added images/guard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions lib/guard/notifiers/gntp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module GNTP
# Default options for the ruby gtnp gem
DEFAULTS = {
:sticky => false,
:host => 'localhost',
:host => '127.0.0.1',
:password => '',
:port => 23053
}
Expand Down Expand Up @@ -91,12 +91,15 @@ def notify(type, title, message, image, options = { })
gntp = ::GNTP.new('Guard', options.delete(:host), options.delete(:password), options.delete(:port))

unless registered?
gntp.register(:notifications => [
{ :name => 'notify', :enabled => true },
{ :name => 'failed', :enabled => true },
{ :name => 'pending', :enabled => true },
{ :name => 'success', :enabled => true }
])
gntp.register({
:app_icon => File.expand_path(File.join(__FILE__, '..', '..', '..', '..', 'images', 'guard.png')),
:notifications => [
{ :name => 'notify', :enabled => true },
{ :name => 'failed', :enabled => true },
{ :name => 'pending', :enabled => true },
{ :name => 'success', :enabled => true }
]
})

registered!
end
Expand Down
2 changes: 1 addition & 1 deletion spec/guard/notifiers/gntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def self.notify(options) end
end

it 'opens GNTP as Guard application' do
::GNTP.should_receive(:new).with('Guard', 'localhost', '', 23053)
::GNTP.should_receive(:new).with('Guard', '127.0.0.1', '', 23053)
subject.notify('success', 'Welcome', 'Welcome to Guard', '/tmp/welcome.png', { })
end

Expand Down

0 comments on commit 479d9b9

Please sign in to comment.