fixed typo and updated relativize_paths regex
This commit is contained in:
parent
ec463a271b
commit
d9fc071492
@ -24,13 +24,13 @@ module Guard
|
|||||||
# @option options [Array<String>] group the list of groups to start
|
# @option options [Array<String>] group the list of groups to start
|
||||||
# @option options [String] watchdir the director to watch
|
# @option options [String] watchdir the director to watch
|
||||||
# @option options [String] guardfile the path to the Guardfile
|
# @option options [String] guardfile the path to the Guardfile
|
||||||
# @optuin options [Boolean] watch_all_modifications watches all file modifications if true
|
# @option options [Boolean] watch_all_modifications watches all file modifications if true
|
||||||
def setup(options = {})
|
def setup(options = {})
|
||||||
@options = options
|
@options = options
|
||||||
@guards = []
|
@guards = []
|
||||||
@groups = [:default]
|
@groups = [:default]
|
||||||
@interactor = Interactor.new
|
@interactor = Interactor.new
|
||||||
@listener = Listener.select_and_init(@options[:watchdir] ? File.expand_path(@options[:watchdir]) : Dir.pwd,options)
|
@listener = Listener.select_and_init(@options[:watchdir] ? File.expand_path(@options[:watchdir]) : Dir.pwd, options)
|
||||||
|
|
||||||
@watch_all_modifications = options[:watch_all_modifications]
|
@watch_all_modifications = options[:watch_all_modifications]
|
||||||
@options[:notify] && ENV['GUARD_NOTIFY'] != 'false' ? Notifier.turn_on : Notifier.turn_off
|
@options[:notify] && ENV['GUARD_NOTIFY'] != 'false' ? Notifier.turn_on : Notifier.turn_off
|
||||||
|
@ -126,8 +126,12 @@ module Guard
|
|||||||
|
|
||||||
# Get the modified files.
|
# Get the modified files.
|
||||||
#
|
#
|
||||||
|
# If watch_all_modifications is true then moved and deleted files are also appended
|
||||||
|
# to the returned array prefixed so !/home/user/dir/file.rb
|
||||||
|
#
|
||||||
# @param [Array<String>] dirs the watched directories
|
# @param [Array<String>] dirs the watched directories
|
||||||
# @param [Hash] options the listener options
|
# @param [Hash] options the listener options
|
||||||
|
# @return [Array<String>] paths of files that have been modified
|
||||||
#
|
#
|
||||||
def modified_files(dirs, options = {})
|
def modified_files(dirs, options = {})
|
||||||
last_event = @last_event
|
last_event = @last_event
|
||||||
@ -172,8 +176,7 @@ module Guard
|
|||||||
def relativize_paths(paths)
|
def relativize_paths(paths)
|
||||||
return paths unless relativize_paths?
|
return paths unless relativize_paths?
|
||||||
paths.map do |path|
|
paths.map do |path|
|
||||||
path.gsub(%r{#{@directory}/}, '')
|
path.gsub(%r{^(!)?#{ @directory }/},'\1')
|
||||||
#path.gsub(%r{^#{ @directory }/}, '')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -274,6 +277,11 @@ module Guard
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Set save a files current timestamp
|
||||||
|
#
|
||||||
|
# @param [String] path the file path
|
||||||
|
# @param [Int] file_timestamp the files modified timestamp
|
||||||
|
#
|
||||||
def set_file_timestamp_hash(path, file_timestamp)
|
def set_file_timestamp_hash(path, file_timestamp)
|
||||||
@file_timestamp_hash[path] = file_timestamp
|
@file_timestamp_hash[path] = file_timestamp
|
||||||
end
|
end
|
||||||
@ -287,6 +295,11 @@ module Guard
|
|||||||
@sha1_checksums_hash[path] = sha1_checksum
|
@sha1_checksums_hash[path] = sha1_checksum
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Gets a files modified timestamp
|
||||||
|
#
|
||||||
|
# @path [String] path the file path
|
||||||
|
# @return [Int] file modified timestamp
|
||||||
|
#
|
||||||
def file_timestamp(path)
|
def file_timestamp(path)
|
||||||
File.mtime(path).to_i
|
File.mtime(path).to_i
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user