Merge branch 'nestegg' of git://github.com/nestegg/guard into nestegg-watchdir_and_guardfile_cli_options
This commit is contained in:
commit
a366e0f8dd
@ -1,4 +1,4 @@
|
||||
guard :rspec, :version => 2, :keep_failed => false, :cli => '-f doc' do
|
||||
guard 'rspec', :version => 2, :keep_failed => false, :cli => '-f doc' do
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
|
9
lib/core_ext/hash_with_indifferent_access.rb
Normal file
9
lib/core_ext/hash_with_indifferent_access.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class Thor
|
||||
module CoreExt #:nodoc:
|
||||
class HashWithIndifferentAccess < ::Hash #:nodoc:
|
||||
def has_key?(key)
|
||||
super(convert_key(key))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,3 +1,6 @@
|
||||
require 'core_ext/hash_with_indifferent_access'
|
||||
#require 'pry'
|
||||
|
||||
module Guard
|
||||
|
||||
autoload :UI, 'guard/ui'
|
||||
@ -14,7 +17,7 @@ module Guard
|
||||
# initialize this singleton
|
||||
def setup(options = {})
|
||||
@options = options
|
||||
@listener = Listener.select_and_init
|
||||
@listener = Listener.select_and_init((options[:watchdir]) ? File.expand_path(options[:watchdir]) : Dir.pwd)
|
||||
@guards = []
|
||||
|
||||
@options[:notify] && ENV["GUARD_NOTIFY"] != 'false' ? Notifier.turn_on : Notifier.turn_off
|
||||
@ -35,7 +38,7 @@ module Guard
|
||||
run { run_on_change_for_all_guards(files) } if Watcher.match_files?(guards, files)
|
||||
end
|
||||
|
||||
UI.info "Guard is now watching at '#{Dir.pwd}'"
|
||||
UI.info "Guard is now watching at '#{listener.directory}'"
|
||||
guards.each { |guard| supervised_task(guard, :start) }
|
||||
listener.start
|
||||
end
|
||||
@ -50,7 +53,7 @@ module Guard
|
||||
end
|
||||
|
||||
# Reparse the whole directory to catch new files modified during the guards run
|
||||
new_modified_files = listener.modified_files([Dir.pwd], :all => true)
|
||||
new_modified_files = listener.modified_files([listener.directory], :all => true)
|
||||
if !new_modified_files.empty? && Watcher.match_files?(guards, new_modified_files)
|
||||
run { run_on_change_for_all_guards(new_modified_files) }
|
||||
end
|
||||
|
@ -10,6 +10,9 @@ module Guard
|
||||
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"
|
||||
|
||||
method_option :guardfile, :type => :string, :aliases => '-C', :banner => "Specify a Guardfile"
|
||||
method_option :watchdir, :type => :string, :default => '.', :aliases => '-w', :banner => "Specify the directory to watch"
|
||||
|
||||
desc "start", "Starts Guard"
|
||||
def start
|
||||
::Guard.start(options)
|
||||
|
@ -9,6 +9,8 @@ module Guard
|
||||
autoload :Polling, 'guard/listeners/polling'
|
||||
|
||||
class Listener
|
||||
|
||||
attr_reader :directory
|
||||
|
||||
def self.select_and_init(*a)
|
||||
if mac? && Darwin.usable?
|
||||
|
Loading…
Reference in New Issue
Block a user