Skip to content

Commit

Permalink
Move sorted glob to FileList
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Nov 14, 2012
1 parent 698a549 commit 438503b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def has_chain?(exception)
def have_rakefile
@rakefiles.each do |fn|
if File.exist?(fn)
others = Rake.glob(fn, File::FNM_CASEFOLD)
others = FileList.glob(fn, File::FNM_CASEFOLD)
return others.size == 1 ? others.first : fn
elsif fn == ''
return fn
Expand Down Expand Up @@ -609,7 +609,7 @@ def raw_load_rakefile # :nodoc:
end

def glob(path, &block)
Rake.glob(path.gsub("\\", '/')).each(&block)
FileList.glob(path.gsub("\\", '/')).each(&block)
end
private :glob

Expand Down
3 changes: 1 addition & 2 deletions lib/rake/contrib/ftptools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ def makedirs(path)
# Upload all files matching +wildcard+ to the uploader's root
# path.
def upload_files(wildcard)
fail "OUCH"
Rake.glob(wildcard).each do |fn|
FileList.glob(wildcard).each do |fn|
upload(fn)
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/rake/contrib/sys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Sys
# Install all the files matching +wildcard+ into the +dest_dir+
# directory. The permission mode is set to +mode+.
def install(wildcard, dest_dir, mode)
Rake.glob(wildcard).each do |fn|
FileList.glob(wildcard).each do |fn|
File.install(fn, dest_dir, mode, $verbose)
end
end
Expand Down Expand Up @@ -81,7 +81,7 @@ def symlink_files(wildcard, dest_dir)
# recursively delete directories.
def delete(*wildcards)
wildcards.each do |wildcard|
Rake.glob(wildcard).each do |fn|
FileList.glob(wildcard).each do |fn|
if File.directory?(fn)
log "Deleting directory #{fn}"
Dir.delete(fn)
Expand All @@ -96,10 +96,10 @@ def delete(*wildcards)
# Recursively delete all files and directories matching +wildcard+.
def delete_all(*wildcards)
wildcards.each do |wildcard|
Rake.glob(wildcard).each do |fn|
FileList.glob(wildcard).each do |fn|
next if ! File.exist?(fn)
if File.directory?(fn)
Rake.glob("#{fn}/*").each do |subfn|
FileList.glob("#{fn}/*").each do |subfn|
next if subfn=='.' || subfn=='..'
delete_all(subfn)
end
Expand Down Expand Up @@ -161,7 +161,7 @@ def verbose(&block)
# Perform a block with each file matching a set of wildcards.
def for_files(*wildcards)
wildcards.each do |wildcard|
Rake.glob(wildcard).each do |fn|
FileList.glob(wildcard).each do |fn|
yield(fn)
end
end
Expand All @@ -172,7 +172,7 @@ def for_files(*wildcards)
private # ----------------------------------------------------------

def for_matching_files(wildcard, dest_dir)
Rake.glob(wildcard).each do |fn|
FileList.glob(wildcard).each do |fn|
dest_file = File.join(dest_dir, fn)
parent = File.dirname(dest_file)
makedirs(parent) if ! File.directory?(parent)
Expand Down
7 changes: 0 additions & 7 deletions lib/rake/rake_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ def add_rakelib(*files)
application.options.rakelib << file
end
end

# Get a sorted list of files matching the pattern. This method
# should be prefered to Dir[pattern] and Dir.glob[pattern] because
# the files returned are guaranteed to be sorted.
def glob(pattern, *args)
Dir.glob(pattern, *args).sort
end
end

end
2 changes: 1 addition & 1 deletion lib/rake/runtest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Rake
include Test::Unit::Assertions

def run_tests(pattern='test/test*.rb', log_enabled=false)
Rake.glob(pattern).each { |fn|
FileList.glob(pattern).each { |fn|
$stderr.puts fn if log_enabled
begin
require fn
Expand Down

0 comments on commit 438503b

Please sign in to comment.