Merge branch 'master' of github.com:guard/guard

This commit is contained in:
Thibaud Guillaume-Gentil 2011-05-28 17:53:27 +02:00
commit 85ed0f8217
4 changed files with 48 additions and 0 deletions

View File

@ -15,4 +15,5 @@ end
if Config::CONFIG['target_os'] =~ /mswin|mingw/i if Config::CONFIG['target_os'] =~ /mswin|mingw/i
gem 'win32console', :require => false gem 'win32console', :require => false
gem 'rb-fchange', '>= 0.0.2', :require => false gem 'rb-fchange', '>= 0.0.2', :require => false
gem 'rb-notifu', '>= 0.0.4', :require => false
end end

View File

@ -16,6 +16,8 @@ module Guard
require_growl require_growl
when /linux/i when /linux/i
require_libnotify require_libnotify
when /mswin|mingw/i
require_rbnotifu
end end
end end
@ -30,6 +32,9 @@ module Guard
when /linux/i when /linux/i
require_libnotify # need for guard-rspec formatter that is called out of guard scope require_libnotify # need for guard-rspec formatter that is called out of guard scope
Libnotify.show :body => message, :summary => title, :icon_path => image_path(image) Libnotify.show :body => message, :summary => title, :icon_path => image_path(image)
when /mswin|mingw/i
require_rbnotifu
Notifu.show :message => message, :title => title, :type => image_level(image), :time => 3
end end
end end
end end
@ -55,6 +60,19 @@ module Guard
end end
end end
def self.image_level(image)
case image
when :failed
:error
when :pending
:warn
when :success
:info
else
:info
end
end
def self.require_growl def self.require_growl
require 'growl' require 'growl'
rescue LoadError rescue LoadError
@ -69,5 +87,11 @@ module Guard
UI.info "Please install libnotify gem for Linux notification support and add it to your Gemfile" UI.info "Please install libnotify gem for Linux notification support and add it to your Gemfile"
end end
def self.require_rbnotifu
require 'rb-notifu'
rescue LoadError
turn_off
UI.info "Please install rb-notifu gem for Windows notification support and add it to your Gemfile"
end
end end
end end

View File

@ -36,6 +36,22 @@ describe Guard::Notifier do
it { should_not be_enabled } it { should_not be_enabled }
end end
end end
if windows?
if rbnotifu_installed?
it "uses rb-notifu on Windows" do
@result = -1
Notifu::show :message => "great", :title => 'Guard' do |status|
@result = status
end
sleep 1.5
Notifu::ERRORS.include?(@result).should be_false
end
else
it { should_not be_enabled }
end
end
end end
describe ".turn_off" do describe ".turn_off" do

View File

@ -11,3 +11,10 @@ def libnotify_installed?
rescue LoadError rescue LoadError
false false
end end
def rbnotifu_installed?
require 'rb-notifu'
true
rescue LoadError
false
end