Skip to content

Commit

Permalink
Merge pull request ruby#122 from joliss/glob-order
Browse files Browse the repository at this point in the history
Make glob order alphabetical, not file-system dependent
  • Loading branch information
jimweirich committed Oct 13, 2012
2 parents aef4446 + 9761c72 commit 5e46fc7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def installBIN(from, opfile)

# The library files

files = Dir.chdir('lib') { Dir['**/*.rb'] }
files = Dir.chdir('lib') { Dir['**/*.rb'].sort }

for fn in files
fn_dir = File.dirname(fn)
Expand Down
4 changes: 2 additions & 2 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def has_chain?(exception)
def have_rakefile
@rakefiles.each do |fn|
if File.exist?(fn)
others = Dir.glob(fn, File::FNM_CASEFOLD)
others = Dir.glob(fn, File::FNM_CASEFOLD).sort
return others.size == 1 ? others.first : fn
elsif fn == ''
return fn
Expand Down Expand Up @@ -512,7 +512,7 @@ def raw_load_rakefile # :nodoc:
end

def glob(path, &block)
Dir[path.gsub("\\", '/')].each(&block)
Dir[path.gsub("\\", '/')].sort.each(&block)
end
private :glob

Expand Down
2 changes: 1 addition & 1 deletion lib/rake/contrib/ftptools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def makedirs(path)
# Upload all files matching +wildcard+ to the uploader's root
# path.
def upload_files(wildcard)
Dir[wildcard].each do |fn|
Dir[wildcard].sort.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)
Dir[wildcard].each do |fn|
Dir[wildcard].sort.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|
Dir[wildcard].each do |fn|
Dir[wildcard].sort.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|
Dir[wildcard].each do |fn|
Dir[wildcard].sort.each do |fn|
next if ! File.exist?(fn)
if File.directory?(fn)
Dir["#{fn}/*"].each do |subfn|
Dir["#{fn}/*"].sort.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|
Dir[wildcard].each do |fn|
Dir[wildcard].sort.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)
Dir[wildcard].each do |fn|
Dir[wildcard].sort.each do |fn|
dest_file = File.join(dest_dir, fn)
parent = File.dirname(dest_file)
makedirs(parent) if ! File.directory?(parent)
Expand Down
2 changes: 1 addition & 1 deletion lib/rake/file_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def to_s

# Add matching glob patterns.
def add_matching(pattern)
Dir[pattern].each do |fn|
Dir[pattern].sort.each do |fn|
self << fn unless exclude?(fn)
end
end
Expand Down
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)
Dir["#{pattern}"].each { |fn|
Dir["#{pattern}"].sort.each { |fn|
$stderr.puts fn if log_enabled
begin
require fn
Expand Down

0 comments on commit 5e46fc7

Please sign in to comment.