Codaisseur/terminal-notifier-guard

Not working with guard, and unclear documentation.

mrjoshuak opened this issue · 9 comments

First of all the Readme.md is confusing on how normal operation is expected to work. The usage section starts with "You could also use the notifier directly." Also? Also as apposed to what? You can't start by saying 'also', you have to first state what is the normal usage, then you can say "also" to add additional usage instructions.

On top of this the examples don't mean anything. What is the context in which TerminalNotifier::Guard.notify('Hello World') should appear? Not on the command line, not in irb, not in the guard file. Where? Did you forget to specify a requires line, is this a rake task?

So the question is:

Is it supposed to 'just work'(tm)? If that is the case then I have a bug in functionality to report.

or

Am I supposed to do something to my guard file to get it to work? In that case I have a documentation bug to report.

Here are the steps to reproduce the issue I'm having.

Mac OS X 10.10.2 in terminal.

  1. > brew install terminal-notifier

  2. > terminal-notifier

    terminal-notifier (1.6.2) is a command-line tool to send OS X User Notifications.
    ...
    
  3. Added gem 'terminal-notifier-guard', '~> 1.6.1' to Gemfile.

  4. > bundle install

    Fetching gem metadata from https://rubygems.org/...........
    Resolving dependencies...
    ...
    Installing terminal-notifier-guard 1.6.1
    ...
    
  5. bundle exec guard

    Guard file looks like:

    guard :shell, first_match: true do
      watch(/(.*)(?<!\.nn|\.y).go$/) {|m| `make` }
      watch(/(.*).nn$/) {|m| `make` }
      watch(/(.*).y$/) {|m| `make` }
    end

    I get expected / typical guard output, but no notification appears.

  6. However, if I run > terminal-notifier -message "test" I get a notification as expected.

Am I missing a step or is there a bug?
I've tried to read through various issues(*) but it quickly turns into a game of portal as each issue refers to other which refer to still other issues which then refer to pull requests which then refer back to the starting issue. It is un-clear which, if any, of these should be followed. I tried a couple of suggestions, and a PR, but none of those changed the behavior described above.

*Issues

#22
#13
#12
#15

guard/guard#626
julienXX#106
...

Looks like adding this to Guardfile does the magic:

notification :terminal_notifier

Seems like a documentation bug.

@mjtko didn't help me.

mjtko commented

@NARKOZ does terminal-notifier -message "test" work?

Adding that notification line to my Guardfile was the only other thing I needed to do (other than brew install terminal-notifier && brew linkapps terminal-notifier)

@mjtko no. It freezes and I need to kill it via Ctrl+C

$ which terminal-notifier          
/usr/local/bin/terminal-notifier

UPD: seems that's because I'm running it from tmux.

mjtko commented

Ah - need to make that work first then! Perhaps this will help? julienXX#115

I use zsh and rvm. Guard does not touch terminal-notifier when I start it without bundle exec. But it works fine if I start it with bundle exec guard.

This is for anyone else who runs into this issue. I needed to add a require 'terminal-notifier-guard' (note the hyphens) — I was using underscores earlier. Looks like the require needs hyphens whereas the gem uses underscores.

With the require statement corrected, I am able to display OS X notifications in irb as well as in the Guardfile

I ran into this issue as well. It turns out things were failing for me because of tmux. Here is a fix for using terminal-notifier-guard with tmux.

Thanks all for reporting. I updated the README with some extra clarification on these and other matters.

Cheers!