diff options
Diffstat (limited to 'lib/rake/file_list.rb')
-rw-r--r-- | lib/rake/file_list.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index b01dbbb341..006ec7703e 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -49,7 +49,7 @@ module Rake # List of methods that should not be delegated here (we define special # versions of them explicitly below). - MUST_NOT_DEFINE = %w[to_a to_ary partition *] + MUST_NOT_DEFINE = %w[to_a to_ary partition * <<] # List of delegated methods that return new array values which need # wrapping. @@ -119,7 +119,7 @@ module Rake if fn.respond_to? :to_ary include(*fn.to_ary) else - @pending_add << fn + @pending_add << Rake.from_pathname(fn) end end @pending = true @@ -149,7 +149,7 @@ module Rake # def exclude(*patterns, &block) patterns.each do |pat| - @exclude_patterns << pat + @exclude_patterns << Rake.from_pathname(pat) end @exclude_procs << block if block_given? resolve_exclude unless @pending @@ -196,6 +196,12 @@ module Rake end end + def <<(obj) + resolve + @items << Rake.from_pathname(obj) + self + end + # Resolve all the pending adds now. def resolve if @pending @@ -346,7 +352,7 @@ module Rake # Should the given file name be excluded from the list? # - # NOTE: This method was formally named "exclude?", but Rails + # NOTE: This method was formerly named "exclude?", but Rails # introduced an exclude? method as an array method and setup a # conflict with file list. We renamed the method to avoid # confusion. If you were using "FileList#exclude?" in your user @@ -410,5 +416,13 @@ module Rake dir = File.dirname(dir) end end + + # Convert Pathname and Pathname-like objects to strings; + # leave everything else alone + def from_pathname(path) # :nodoc: + path = path.to_path if path.respond_to?(:to_path) + path = path.to_str if path.respond_to?(:to_str) + path + end end end # module Rake |