Merge branch 'master' of github.com:guard/guard
This commit is contained in:
commit
85ed0f8217
1
Gemfile
1
Gemfile
@ -15,4 +15,5 @@ end
|
||||
if Config::CONFIG['target_os'] =~ /mswin|mingw/i
|
||||
gem 'win32console', :require => false
|
||||
gem 'rb-fchange', '>= 0.0.2', :require => false
|
||||
gem 'rb-notifu', '>= 0.0.4', :require => false
|
||||
end
|
||||
|
@ -16,6 +16,8 @@ module Guard
|
||||
require_growl
|
||||
when /linux/i
|
||||
require_libnotify
|
||||
when /mswin|mingw/i
|
||||
require_rbnotifu
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,6 +32,9 @@ module Guard
|
||||
when /linux/i
|
||||
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)
|
||||
when /mswin|mingw/i
|
||||
require_rbnotifu
|
||||
Notifu.show :message => message, :title => title, :type => image_level(image), :time => 3
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -55,6 +60,19 @@ module Guard
|
||||
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
|
||||
require 'growl'
|
||||
rescue LoadError
|
||||
@ -69,5 +87,11 @@ module Guard
|
||||
UI.info "Please install libnotify gem for Linux notification support and add it to your Gemfile"
|
||||
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
|
||||
|
@ -36,6 +36,22 @@ describe Guard::Notifier do
|
||||
it { should_not be_enabled }
|
||||
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
|
||||
|
||||
describe ".turn_off" do
|
||||
|
@ -11,3 +11,10 @@ def libnotify_installed?
|
||||
rescue LoadError
|
||||
false
|
||||
end
|
||||
|
||||
def rbnotifu_installed?
|
||||
require 'rb-notifu'
|
||||
true
|
||||
rescue LoadError
|
||||
false
|
||||
end
|
Loading…
Reference in New Issue
Block a user