Skip to content

Commit

Permalink
some refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Oct 9, 2013
1 parent 60fa141 commit cca964a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
# encoding: utf-8

require 'terminal-notifier'

def which cmd
dir = ENV['PATH'].split(':').find {|p| File.executable? File.join(p, cmd)}
File.join(dir, cmd) unless dir.nil?
end

def notify m
msg = "'#{m}\\n#{Time.now.to_s}'"
msg = "'#{m.gsub(/'/, "''")}\\n#{Time.now.to_s}'"
case
when which('terminal-notifier')
`terminal-notifier -message #{msg}`
when which('notify-send')
`notify-send #{msg}`
when which('tmux')
`tmux display-message #{msg}` if `tmux list-clients 1>/dev/null 2>&1` && $?.success?
`tmux display-message #{msg}` if system('tmux list-clients 1>/dev/null 2>&1')
end
end

guard :shell do
watch /^(autoload|plugin|t)\/.+\.vim$/ do
system "rake test"
unless $?.success?
notify "test(s) failed"
end
notify "test(s) failed" unless $?.success?
end
end

0 comments on commit cca964a

Please sign in to comment.