Add #supported?
method for libnotify and notify-send
This commit is contained in:
parent
72eefab5f2
commit
cd38483ab7
@ -1 +1,16 @@
|
||||
begin
|
||||
require 'libnotify'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
module Capistrano
|
||||
module Send
|
||||
module Libnotify
|
||||
def self.supported?
|
||||
defined?(Libnotify) && Libnotify::API.instance_methods.include?(:notify_init)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
load File.expand_path('../../tasks/libnotify.cap', __FILE__)
|
||||
|
@ -1 +1,11 @@
|
||||
module Capistrano
|
||||
module Send
|
||||
module NotifySend
|
||||
def self.supported?
|
||||
system('notify-send --version >/dev/null 2>&1') != nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
load File.expand_path('../../tasks/notify-send.cap', __FILE__)
|
||||
|
@ -1,13 +1,8 @@
|
||||
begin
|
||||
require 'libnotify'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
namespace :send do
|
||||
namespace :libnotify do
|
||||
desc "Display a notification using libnotify"
|
||||
task :notify do
|
||||
if defined?(Libnotify)
|
||||
if Capistrano::Send::Libnotify.supported?
|
||||
Libnotify.show(
|
||||
summary: "Deploy successful on #{fetch(:stage)}!",
|
||||
body: revision_log_message,
|
||||
|
@ -2,11 +2,13 @@ namespace :send do
|
||||
namespace :'notify-send' do
|
||||
desc "Display a notification using notify-send"
|
||||
task :notify do
|
||||
expire_time = 10000
|
||||
summary = "Deploy successful on #{fetch(:stage)}!"
|
||||
body = revision_log_message
|
||||
if Capistrano::Send::NotifySend.supported?
|
||||
expire_time = 10000
|
||||
summary = "Deploy successful on #{fetch(:stage)}!"
|
||||
body = revision_log_message
|
||||
|
||||
`notify-send --expire-time=#{expire_time} '#{summary}' '#{body}'`
|
||||
`notify-send --expire-time=#{expire_time} '#{summary}' '#{body}'`
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user