Removed growl & libnotify dependencies from gemspec

This commit is contained in:
Thibaud Guillaume-Gentil 2010-10-19 21:49:17 +02:00
parent a9d31d292a
commit 6db69c1b6a
3 changed files with 28 additions and 14 deletions

View File

@ -15,15 +15,11 @@ Gem::Specification.new do |s|
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = 'guard'
s.add_development_dependency 'rspec', '~> 2.0.0'
s.add_development_dependency 'rspec', '~> 2.0.1'
s.add_development_dependency 'guard-rspec', '~> 0.1.3'
s.add_dependency 'bundler', '~> 1.0.2'
s.add_dependency 'thor', '~> 0.14.3'
# Mac OS X
s.add_dependency 'growl', '~> 1.0.3'
# Linux
s.add_dependency 'libnotify', '~> 0.1.3'
s.files = Dir.glob('{bin,images,lib}/**/*') + %w[LICENSE README.rdoc]
s.executable = 'guard'

View File

@ -1,13 +1,6 @@
require 'rbconfig'
require 'pathname'
case Config::CONFIG['target_os']
when /darwin/i
require 'growl'
when /linux/i
require 'libnotify'
end
module Guard
module Notifier
@ -17,9 +10,13 @@ module Guard
title = options[:title] || "Guard"
case Config::CONFIG['target_os']
when /darwin/i
Growl.notify message, :title => title, :icon => image_path(image), :name => "Guard"
if growl_installed?
Growl.notify message, :title => title, :icon => image_path(image), :name => "Guard"
end
when /linux/i
Libnotify.show :body => message, :summary => title, :icon_path => image_path(image)
if libnotify_installed?
Libnotify.show :body => message, :summary => title, :icon_path => image_path(image)
end
end
end
end
@ -41,5 +38,25 @@ module Guard
end
end
def self.growl_installed?
@installed ||= begin
require 'growl'
true
rescue LoadError
UI.info "Please install growl gem for Mac OS X notification support"
false
end
end
def self.libnotify_installed?
@installed ||= begin
require 'libnotify'
true
rescue LoadError
UI.info "Please install libnotify gem for Linux notification support"
false
end
end
end
end

View File

@ -7,6 +7,7 @@ describe Guard::Notifier do
before(:each) { ENV["GUARD_ENV"] = 'special_test' }
if mac?
require 'growl'
it "should use Growl on Mac OS X" do
Growl.should_receive(:notify).with("great",
:title => "Guard",