Added a command line option (-n false) to disable notifications (growl/libnotify). closed #28
This commit is contained in:
parent
31c43f7c13
commit
42c27242e1
@ -17,6 +17,9 @@ module Guard
|
|||||||
@options = options
|
@options = options
|
||||||
@listener = Listener.select_and_init
|
@listener = Listener.select_and_init
|
||||||
@guards = []
|
@guards = []
|
||||||
|
|
||||||
|
Notifier.turn_off unless options[:notify]
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,9 +5,10 @@ module Guard
|
|||||||
class CLI < Thor
|
class CLI < Thor
|
||||||
default_task :start
|
default_task :start
|
||||||
|
|
||||||
method_option :clear, :type => :boolean, :default => false, :aliases => '-c', :banner => "Auto clear shell before each change/run_all/reload"
|
method_option :clear, :type => :boolean, :default => false, :aliases => '-c', :banner => "Auto clear shell before each change/run_all/reload"
|
||||||
method_option :debug, :type => :boolean, :default => false, :aliases => '-d', :banner => "Print debug messages"
|
method_option :notify, :type => :boolean, :default => true, :aliases => '-n', :banner => "Notifications feature (growl/libnotify)"
|
||||||
method_option :group, :type => :array, :default => [], :aliases => '-g', :banner => "Run only the passed groups"
|
method_option :debug, :type => :boolean, :default => false, :aliases => '-d', :banner => "Print debug messages"
|
||||||
|
method_option :group, :type => :array, :default => [], :aliases => '-g', :banner => "Run only the passed groups"
|
||||||
|
|
||||||
desc "start", "Starts Guard"
|
desc "start", "Starts Guard"
|
||||||
def start
|
def start
|
||||||
|
@ -4,8 +4,12 @@ require 'pathname'
|
|||||||
module Guard
|
module Guard
|
||||||
module Notifier
|
module Notifier
|
||||||
|
|
||||||
|
def self.turn_off
|
||||||
|
@disable = true
|
||||||
|
end
|
||||||
|
|
||||||
def self.notify(message, options = {})
|
def self.notify(message, options = {})
|
||||||
unless ENV["GUARD_ENV"] == "test"
|
unless @disable || ENV["GUARD_ENV"] == "test"
|
||||||
image = options[:image] || :success
|
image = options[:image] || :success
|
||||||
title = options[:title] || "Guard"
|
title = options[:title] || "Guard"
|
||||||
case Config::CONFIG['target_os']
|
case Config::CONFIG['target_os']
|
||||||
|
@ -30,6 +30,26 @@ describe Guard::Notifier do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "turned off" do
|
||||||
|
before(:each) { subject.turn_off }
|
||||||
|
|
||||||
|
if mac?
|
||||||
|
require 'growl'
|
||||||
|
it "should do nothing" do
|
||||||
|
Growl.should_not_receive(:notify)
|
||||||
|
subject.notify 'great', :title => 'Guard'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if linux?
|
||||||
|
require 'libnotify'
|
||||||
|
it "should do nothing" do
|
||||||
|
Libnotify.should_not_receive(:show)
|
||||||
|
subject.notify 'great', :title => 'Guard'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
after(:each) { ENV["GUARD_ENV"] = 'test' }
|
after(:each) { ENV["GUARD_ENV"] = 'test' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ describe Guard do
|
|||||||
it "should init listener" do
|
it "should init listener" do
|
||||||
::Guard.listener.should be_kind_of(Guard::Listener)
|
::Guard.listener.should be_kind_of(Guard::Listener)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should turn off notifier if notify option is false" do
|
||||||
|
::Guard::Notifier.should_receive(:turn_off)
|
||||||
|
::Guard.setup(:notify => false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".get_guard_class" do
|
describe ".get_guard_class" do
|
||||||
|
Loading…
Reference in New Issue
Block a user