windows notifiaction
This commit is contained in:
parent
51750c6d1a
commit
02448b8575
1
Gemfile
1
Gemfile
@ -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', :require => false
|
||||||
end
|
end
|
||||||
|
@ -15,6 +15,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
|
||||||
|
|
||||||
@ -29,6 +31,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
|
||||||
|
RbNotifu.show :message => message, :title => title, :type => image_level(image)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -54,6 +59,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
|
||||||
@ -68,5 +86,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 'rbnotifu'
|
||||||
|
rescue LoadError
|
||||||
|
turn_off
|
||||||
|
UI.info "Please install rbnotifu gem for Windows notification support and add it to your Gemfile"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -36,6 +36,21 @@ 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 rbnotifu on Windows" do
|
||||||
|
RbNotifu::show(
|
||||||
|
:message => "great",
|
||||||
|
:title => 'Guard',
|
||||||
|
:type => :info
|
||||||
|
)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
it { should_not be_enabled }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".turn_off" do
|
describe ".turn_off" do
|
||||||
@ -49,6 +64,10 @@ describe Guard::Notifier do
|
|||||||
Libnotify.should_not_receive(:show)
|
Libnotify.should_not_receive(:show)
|
||||||
subject.notify 'great', :title => 'Guard'
|
subject.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
elsif windows? && rbnotifu_installed?
|
||||||
|
it "prevents the notifications" do
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should_not be_enabled }
|
it { should_not be_enabled }
|
||||||
|
@ -10,4 +10,11 @@ def libnotify_installed?
|
|||||||
true
|
true
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
false
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def rbnotifu_installed?
|
||||||
|
require 'rb-notifu'
|
||||||
|
true
|
||||||
|
rescue LoadError
|
||||||
|
false
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user