Skip to content

Commit

Permalink
Add FileList.glob to avoid unwanted dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Nov 14, 2012
1 parent 8edfcb4 commit 698a549
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 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)
Rake.glob(pattern).each do |fn|
FileList.glob(pattern).each do |fn|
self << fn unless exclude?(fn)
end
end
Expand Down Expand Up @@ -383,6 +383,13 @@ class << self
def [](*args)
new(*args)
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
end
Expand Down
8 changes: 8 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,12 @@ def rakefile_failing_test_task
end
end

def rakefile_stand_alone_filelist
open 'stand_alone_filelist.rb', 'w' do |io|
io << "require 'rake/file_list'\n"
io << "FL = Rake::FileList['*.rb']\n"
io << "puts FL\n"
end
end

end
9 changes: 9 additions & 0 deletions test/test_rake_functional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,15 @@ def test_failing_test_sets_exit_status
assert_equal 1, @exit.exitstatus
end

def test_stand_alone_filelist
rakefile_stand_alone_filelist

run_ruby @ruby_options + ["stand_alone_filelist.rb"]

assert_match(/^stand_alone_filelist\.rb$/, @out)
assert_equal 0, @exit.exitstatus
end

private

# Run a shell Ruby command with command line options (using the
Expand Down

0 comments on commit 698a549

Please sign in to comment.