rake 10.4.2 → 13.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +16 -7
  3. data/Gemfile +10 -0
  4. data/History.rdoc +2022 -287
  5. data/README.rdoc +40 -25
  6. data/Rakefile +25 -65
  7. data/bin/bundle +105 -0
  8. data/bin/console +7 -0
  9. data/bin/rake +20 -24
  10. data/bin/rdoc +29 -0
  11. data/bin/rubocop +29 -0
  12. data/bin/setup +6 -0
  13. data/doc/glossary.rdoc +10 -11
  14. data/doc/jamis.rb +1 -0
  15. data/doc/rake.1 +139 -124
  16. data/doc/rakefile.rdoc +2 -33
  17. data/exe/rake +27 -0
  18. data/lib/rake.rb +35 -43
  19. data/lib/rake/application.rb +125 -91
  20. data/lib/rake/backtrace.rb +3 -2
  21. data/lib/rake/clean.rb +8 -6
  22. data/lib/rake/cloneable.rb +1 -0
  23. data/lib/rake/cpu_counter.rb +10 -28
  24. data/lib/rake/default_loader.rb +1 -0
  25. data/lib/rake/dsl_definition.rb +6 -12
  26. data/lib/rake/early_time.rb +1 -0
  27. data/lib/rake/ext/core.rb +1 -0
  28. data/lib/rake/ext/string.rb +24 -21
  29. data/lib/rake/file_creation_task.rb +4 -3
  30. data/lib/rake/file_list.rb +35 -28
  31. data/lib/rake/file_task.rb +12 -4
  32. data/lib/rake/file_utils.rb +38 -32
  33. data/lib/rake/file_utils_ext.rb +8 -18
  34. data/lib/rake/invocation_chain.rb +1 -0
  35. data/lib/rake/invocation_exception_mixin.rb +1 -0
  36. data/lib/rake/late_time.rb +2 -1
  37. data/lib/rake/linked_list.rb +24 -15
  38. data/lib/rake/loaders/makefile.rb +23 -9
  39. data/lib/rake/multi_task.rb +2 -1
  40. data/lib/rake/name_space.rb +1 -1
  41. data/lib/rake/packagetask.rb +40 -17
  42. data/lib/rake/phony.rb +2 -1
  43. data/lib/rake/private_reader.rb +1 -0
  44. data/lib/rake/promise.rb +13 -12
  45. data/lib/rake/pseudo_status.rb +1 -0
  46. data/lib/rake/rake_module.rb +30 -1
  47. data/lib/rake/rake_test_loader.rb +18 -13
  48. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  49. data/lib/rake/scope.rb +3 -2
  50. data/lib/rake/task.rb +82 -31
  51. data/lib/rake/task_argument_error.rb +1 -0
  52. data/lib/rake/task_arguments.rb +15 -4
  53. data/lib/rake/task_manager.rb +54 -33
  54. data/lib/rake/tasklib.rb +2 -14
  55. data/lib/rake/testtask.rb +40 -63
  56. data/lib/rake/thread_history_display.rb +4 -3
  57. data/lib/rake/thread_pool.rb +16 -17
  58. data/lib/rake/trace_output.rb +2 -1
  59. data/lib/rake/version.rb +4 -1
  60. data/lib/rake/win32.rb +10 -15
  61. data/rake.gemspec +43 -0
  62. metadata +33 -270
  63. data/.autotest +0 -7
  64. data/.gemtest +0 -0
  65. data/.rubocop.yml +0 -27
  66. data/.togglerc +0 -7
  67. data/Manifest.txt +0 -166
  68. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  69. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  70. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  71. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  72. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  73. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  74. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  75. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  76. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  77. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  78. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  79. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  80. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  81. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  82. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  83. data/doc/release_notes/rake-0.8.6.rdoc +0 -37
  84. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  85. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  86. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  87. data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
  88. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  89. data/doc/release_notes/rake-0.9.3.rdoc +0 -102
  90. data/doc/release_notes/rake-0.9.4.rdoc +0 -60
  91. data/doc/release_notes/rake-0.9.5.rdoc +0 -55
  92. data/doc/release_notes/rake-0.9.6.rdoc +0 -64
  93. data/doc/release_notes/rake-10.0.0.rdoc +0 -178
  94. data/doc/release_notes/rake-10.0.1.rdoc +0 -58
  95. data/doc/release_notes/rake-10.0.2.rdoc +0 -53
  96. data/doc/release_notes/rake-10.0.3.rdoc +0 -191
  97. data/doc/release_notes/rake-10.1.0.rdoc +0 -61
  98. data/lib/rake/alt_system.rb +0 -110
  99. data/lib/rake/contrib/.document +0 -1
  100. data/lib/rake/contrib/compositepublisher.rb +0 -21
  101. data/lib/rake/contrib/ftptools.rb +0 -137
  102. data/lib/rake/contrib/publisher.rb +0 -81
  103. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  104. data/lib/rake/contrib/sshpublisher.rb +0 -61
  105. data/lib/rake/contrib/sys.rb +0 -4
  106. data/lib/rake/ext/module.rb +0 -2
  107. data/lib/rake/ext/pathname.rb +0 -25
  108. data/lib/rake/ext/time.rb +0 -16
  109. data/lib/rake/gempackagetask.rb +0 -4
  110. data/lib/rake/pathmap.rb +0 -3
  111. data/lib/rake/rdoctask.rb +0 -4
  112. data/lib/rake/ruby182_test_unit_fix.rb +0 -29
  113. data/lib/rake/runtest.rb +0 -27
  114. data/rakelib/publish.rake +0 -20
  115. data/rakelib/test_times.rake +0 -25
  116. data/test/file_creation.rb +0 -34
  117. data/test/helper.rb +0 -130
  118. data/test/support/rakefile_definitions.rb +0 -478
  119. data/test/support/ruby_runner.rb +0 -34
  120. data/test/test_private_reader.rb +0 -42
  121. data/test/test_rake.rb +0 -40
  122. data/test/test_rake_application.rb +0 -643
  123. data/test/test_rake_application_options.rb +0 -466
  124. data/test/test_rake_backtrace.rb +0 -119
  125. data/test/test_rake_clean.rb +0 -61
  126. data/test/test_rake_cpu_counter.rb +0 -68
  127. data/test/test_rake_definitions.rb +0 -84
  128. data/test/test_rake_directory_task.rb +0 -76
  129. data/test/test_rake_dsl.rb +0 -40
  130. data/test/test_rake_early_time.rb +0 -31
  131. data/test/test_rake_extension.rb +0 -59
  132. data/test/test_rake_file_creation_task.rb +0 -56
  133. data/test/test_rake_file_list.rb +0 -655
  134. data/test/test_rake_file_list_path_map.rb +0 -8
  135. data/test/test_rake_file_task.rb +0 -197
  136. data/test/test_rake_file_utils.rb +0 -309
  137. data/test/test_rake_ftp_file.rb +0 -74
  138. data/test/test_rake_functional.rb +0 -482
  139. data/test/test_rake_invocation_chain.rb +0 -64
  140. data/test/test_rake_late_time.rb +0 -18
  141. data/test/test_rake_linked_list.rb +0 -84
  142. data/test/test_rake_makefile_loader.rb +0 -46
  143. data/test/test_rake_multi_task.rb +0 -64
  144. data/test/test_rake_name_space.rb +0 -57
  145. data/test/test_rake_package_task.rb +0 -79
  146. data/test/test_rake_path_map.rb +0 -168
  147. data/test/test_rake_path_map_explode.rb +0 -34
  148. data/test/test_rake_path_map_partial.rb +0 -18
  149. data/test/test_rake_pathname_extensions.rb +0 -15
  150. data/test/test_rake_pseudo_status.rb +0 -21
  151. data/test/test_rake_rake_test_loader.rb +0 -20
  152. data/test/test_rake_reduce_compat.rb +0 -26
  153. data/test/test_rake_require.rb +0 -40
  154. data/test/test_rake_rules.rb +0 -388
  155. data/test/test_rake_scope.rb +0 -44
  156. data/test/test_rake_task.rb +0 -393
  157. data/test/test_rake_task_argument_parsing.rb +0 -119
  158. data/test/test_rake_task_arguments.rb +0 -127
  159. data/test/test_rake_task_lib.rb +0 -9
  160. data/test/test_rake_task_manager.rb +0 -178
  161. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  162. data/test/test_rake_task_with_arguments.rb +0 -172
  163. data/test/test_rake_test_task.rb +0 -146
  164. data/test/test_rake_thread_pool.rb +0 -145
  165. data/test/test_rake_top_level_functions.rb +0 -71
  166. data/test/test_rake_win32.rb +0 -72
  167. data/test/test_thread_history_display.rb +0 -101
  168. data/test/test_trace_output.rb +0 -52
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
  module Backtrace # :nodoc: all
3
4
  SYS_KEYS = RbConfig::CONFIG.keys.grep(/(?:[a-z]prefix|libdir)\z/)
@@ -5,12 +6,12 @@ module Rake
5
6
  [ File.join(File.dirname(__FILE__), "..") ]
6
7
 
7
8
  SUPPRESSED_PATHS = SYS_PATHS.
8
- map { |s| s.gsub("\\", "/") }.
9
+ map { |s| s.tr("\\", "/") }.
9
10
  map { |f| File.expand_path(f) }.
10
11
  reject { |s| s.nil? || s =~ /^ *$/ }
11
12
  SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|")
12
13
  SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if
13
- Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
14
+ Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == "jruby"
14
15
 
15
16
  SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i
16
17
 
data/lib/rake/clean.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
2
3
  # two rake tasks (:clean and :clobber).
3
4
  #
@@ -11,7 +12,7 @@
11
12
  # The intent of this task is to return a project to its
12
13
  # pristine, just unpacked state.
13
14
 
14
- require 'rake'
15
+ require "rake"
15
16
 
16
17
  # :stopdoc:
17
18
 
@@ -27,9 +28,10 @@ module Rake
27
28
  end
28
29
  end
29
30
 
30
- def cleanup(file_name, opts={})
31
+ def cleanup(file_name, **opts)
31
32
  begin
32
- rm_r file_name, opts
33
+ opts = { verbose: Rake.application.options.trace }.merge(opts)
34
+ rm_r file_name, **opts
33
35
  rescue StandardError => ex
34
36
  puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name)
35
37
  end
@@ -60,7 +62,7 @@ end
60
62
 
61
63
  CLEAN = ::Rake::FileList["**/*~", "**/*.bak", "**/core"]
62
64
  CLEAN.clear_exclude.exclude { |fn|
63
- fn.pathmap("%f").downcase == 'core' && File.directory?(fn)
65
+ fn.pathmap("%f").downcase == "core" && File.directory?(fn)
64
66
  }
65
67
 
66
68
  desc "Remove any temporary products."
@@ -70,7 +72,7 @@ end
70
72
 
71
73
  CLOBBER = ::Rake::FileList.new
72
74
 
73
- desc "Remove any generated file."
74
- task :clobber => [:clean] do
75
+ desc "Remove any generated files."
76
+ task clobber: [:clean] do
75
77
  Rake::Cleaner.cleanup_files(CLOBBER)
76
78
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
  ##
3
4
  # Mixin for creating easily cloned objects.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Based on a script at:
@@ -14,7 +15,7 @@ module Rake
14
15
  end
15
16
 
16
17
  begin
17
- require 'etc'
18
+ require "etc"
18
19
  rescue LoadError
19
20
  else
20
21
  if Etc.respond_to?(:nprocessors)
@@ -30,31 +31,22 @@ unless Rake::CpuCounter.method_defined?(:count)
30
31
  Rake::CpuCounter.class_eval <<-'end;', __FILE__, __LINE__+1
31
32
  require 'rbconfig'
32
33
 
33
- # TODO: replace with IO.popen using array-style arguments in Rake 11
34
- require 'open3'
35
-
36
34
  def count
37
- if defined?(Java::Java)
35
+ if RUBY_PLATFORM == 'java'
38
36
  count_via_java_runtime
39
37
  else
40
38
  case RbConfig::CONFIG['host_os']
41
- when /darwin9/
42
- count_via_hwprefs_cpu_count
43
- when /darwin/
44
- count_via_hwprefs_thread_count || count_via_sysctl
45
39
  when /linux/
46
40
  count_via_cpuinfo
47
- when /bsd/
41
+ when /darwin|bsd/
48
42
  count_via_sysctl
49
43
  when /mswin|mingw/
50
44
  count_via_win32
51
45
  else
52
46
  # Try everything
53
47
  count_via_win32 ||
54
- count_via_sysctl ||
55
- count_via_hwprefs_thread_count ||
56
- count_via_hwprefs_cpu_count ||
57
- count_via_cpuinfo
48
+ count_via_sysctl ||
49
+ count_via_cpuinfo
58
50
  end
59
51
  end
60
52
  end
@@ -80,14 +72,6 @@ unless Rake::CpuCounter.method_defined?(:count)
80
72
  nil
81
73
  end
82
74
 
83
- def count_via_hwprefs_thread_count
84
- run 'hwprefs', 'thread_count'
85
- end
86
-
87
- def count_via_hwprefs_cpu_count
88
- run 'hwprefs', 'cpu_count'
89
- end
90
-
91
75
  def count_via_sysctl
92
76
  run 'sysctl', '-n', 'hw.ncpu'
93
77
  end
@@ -95,10 +79,8 @@ unless Rake::CpuCounter.method_defined?(:count)
95
79
  def run(command, *args)
96
80
  cmd = resolve_command(command)
97
81
  if cmd
98
- Open3.popen3 cmd, *args do |inn, out, err,|
99
- inn.close
100
- err.read
101
- out.read.to_i
82
+ IO.popen [cmd, *args] do |io|
83
+ io.read.to_i
102
84
  end
103
85
  else
104
86
  nil
@@ -117,8 +99,8 @@ unless Rake::CpuCounter.method_defined?(:count)
117
99
  end
118
100
 
119
101
  def in_path_command(command)
120
- Open3.popen3 'which', command do |_, out,|
121
- out.eof? ? nil : command
102
+ IO.popen ['which', command] do |io|
103
+ io.eof? ? nil : command
122
104
  end
123
105
  end
124
106
  end;
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Default Rakefile loader used by +import+.
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  # Rake DSL functions.
2
- require 'rake/file_utils_ext'
3
+ require "rake/file_utils_ext"
3
4
 
4
5
  module Rake
5
6
 
@@ -7,7 +8,7 @@ module Rake
7
8
  # DSL is a module that provides #task, #desc, #namespace, etc. Use this
8
9
  # when you'd like to use rake outside the top level scope.
9
10
  #
10
- # For a Rakefile you run from the comamnd line this module is automatically
11
+ # For a Rakefile you run from the command line this module is automatically
11
12
  # included.
12
13
 
13
14
  module DSL
@@ -25,10 +26,9 @@ module Rake
25
26
  private
26
27
 
27
28
  # :call-seq:
28
- # task task_name
29
- # task task_name: dependencies
30
- # task task_name, arguments => dependencies
31
- # task task_name, argument[, argument ...], :needs: dependencies
29
+ # task(task_name)
30
+ # task(task_name: dependencies)
31
+ # task(task_name, arguments => dependencies)
32
32
  #
33
33
  # Declare a basic task. The +task_name+ is always the first argument. If
34
34
  # the task name contains a ":" it is defined in that namespace.
@@ -56,12 +56,6 @@ module Rake
56
56
  #
57
57
  # $ rake package[1.2.3]
58
58
  #
59
- # Alternate definition:
60
- #
61
- # task :package, :version, needs: :test do |t, args|
62
- # # ...
63
- # end
64
- #
65
59
  def task(*args, &block) # :doc:
66
60
  Rake::Task.define_task(*args, &block)
67
61
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # EarlyTime is a fake timestamp that occurs _before_ any other time value.
data/lib/rake/ext/core.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Module
2
3
  # Check for an existing method in the current class before extending. If
3
4
  # the method already exists, then a warning is printed and the extension is
@@ -1,4 +1,5 @@
1
- require 'rake/ext/core'
1
+ # frozen_string_literal: true
2
+ require "rake/ext/core"
2
3
 
3
4
  class String
4
5
 
@@ -10,9 +11,11 @@ class String
10
11
  # +ext+ is a user added method for the String class.
11
12
  #
12
13
  # This String extension comes from Rake
13
- def ext(newext='')
14
- return self.dup if ['.', '..'].include? self
15
- newext = (newext =~ /^\./) ? newext : ("." + newext) if newext != ''
14
+ def ext(newext="")
15
+ return self.dup if [".", ".."].include? self
16
+ if newext != ""
17
+ newext = "." + newext unless newext =~ /^\./
18
+ end
16
19
  self.chomp(File.extname(self)) << newext
17
20
  end
18
21
  end
@@ -24,8 +27,8 @@ class String
24
27
  def pathmap_explode
25
28
  head, tail = File.split(self)
26
29
  return [self] if head == self
27
- return [tail] if head == '.' || tail == '/'
28
- return [head, tail] if head == '/'
30
+ return [tail] if head == "." || tail == "/"
31
+ return [head, tail] if head == "/"
29
32
  return head.pathmap_explode + [tail]
30
33
  end
31
34
  protected :pathmap_explode
@@ -55,15 +58,15 @@ class String
55
58
  # This String extension comes from Rake
56
59
  def pathmap_replace(patterns, &block)
57
60
  result = self
58
- patterns.split(';').each do |pair|
59
- pattern, replacement = pair.split(',')
61
+ patterns.split(";").each do |pair|
62
+ pattern, replacement = pair.split(",")
60
63
  pattern = Regexp.new(pattern)
61
- if replacement == '*' && block_given?
64
+ if replacement == "*" && block_given?
62
65
  result = result.sub(pattern, &block)
63
66
  elsif replacement
64
67
  result = result.sub(pattern, replacement)
65
68
  else
66
- result = result.sub(pattern, '')
69
+ result = result.sub(pattern, "")
67
70
  end
68
71
  end
69
72
  result
@@ -134,32 +137,32 @@ class String
134
137
  # This String extension comes from Rake
135
138
  def pathmap(spec=nil, &block)
136
139
  return self if spec.nil?
137
- result = ''
140
+ result = "".dup
138
141
  spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
139
142
  case frag
140
- when '%f'
143
+ when "%f"
141
144
  result << File.basename(self)
142
- when '%n'
145
+ when "%n"
143
146
  result << File.basename(self).ext
144
- when '%d'
147
+ when "%d"
145
148
  result << File.dirname(self)
146
- when '%x'
149
+ when "%x"
147
150
  result << File.extname(self)
148
- when '%X'
151
+ when "%X"
149
152
  result << self.ext
150
- when '%p'
153
+ when "%p"
151
154
  result << self
152
- when '%s'
155
+ when "%s"
153
156
  result << (File::ALT_SEPARATOR || File::SEPARATOR)
154
- when '%-'
157
+ when "%-"
155
158
  # do nothing
156
- when '%%'
159
+ when "%%"
157
160
  result << "%"
158
161
  when /%(-?\d+)d/
159
162
  result << pathmap_partial($1.to_i)
160
163
  when /^%\{([^}]*)\}(\d*[dpfnxX])/
161
164
  patterns, operator = $1, $2
162
- result << pathmap('%' + operator).pathmap_replace(patterns, &block)
165
+ result << pathmap("%" + operator).pathmap_replace(patterns, &block)
163
166
  when /^%/
164
167
  fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
165
168
  else
@@ -1,5 +1,6 @@
1
- require 'rake/file_task'
2
- require 'rake/early_time'
1
+ # frozen_string_literal: true
2
+ require "rake/file_task"
3
+ require "rake/early_time"
3
4
 
4
5
  module Rake
5
6
 
@@ -11,7 +12,7 @@ module Rake
11
12
  class FileCreationTask < FileTask
12
13
  # Is this file task needed? Yes if it doesn't exist.
13
14
  def needed?
14
- ! File.exist?(name)
15
+ !File.exist?(name)
15
16
  end
16
17
 
17
18
  # Time stamp for file creation task. This time stamp is earlier
@@ -1,7 +1,7 @@
1
- require 'rake/cloneable'
2
- require 'rake/file_utils_ext'
3
- require 'rake/pathmap'
4
-
1
+ # frozen_string_literal: true
2
+ require "rake/cloneable"
3
+ require "rake/file_utils_ext"
4
+ require "rake/ext/string"
5
5
 
6
6
  module Rake
7
7
 
@@ -41,8 +41,7 @@ module Rake
41
41
 
42
42
  # List of array methods (that are not in +Object+) that need to be
43
43
  # delegated.
44
- ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).
45
- map { |n| n.to_s }
44
+ ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map(&:to_s)
46
45
 
47
46
  # List of additional methods that must be delegated.
48
47
  MUST_DEFINE = %w[inspect <=>]
@@ -59,8 +58,7 @@ module Rake
59
58
  + - & |
60
59
  ]
61
60
 
62
- DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).
63
- map { |s| s.to_s }.sort.uniq
61
+ DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).map(&:to_s).sort.uniq
64
62
 
65
63
  # Now do the delegation.
66
64
  DELEGATING_METHODS.each do |sym|
@@ -70,7 +68,7 @@ module Rake
70
68
  def #{sym}(*args, &block)
71
69
  resolve
72
70
  result = @items.send(:#{sym}, *args, &block)
73
- FileList.new.import(result)
71
+ self.class.new.import(result)
74
72
  end
75
73
  }, __FILE__, ln
76
74
  else
@@ -85,6 +83,8 @@ module Rake
85
83
  end
86
84
  end
87
85
 
86
+ GLOB_PATTERN = %r{[*?\[\{]}
87
+
88
88
  # Create a file list from the globbable patterns given. If you wish to
89
89
  # perform multiple includes or excludes at object build time, use the
90
90
  # "yield self" pattern.
@@ -149,7 +149,11 @@ module Rake
149
149
  #
150
150
  def exclude(*patterns, &block)
151
151
  patterns.each do |pat|
152
- @exclude_patterns << Rake.from_pathname(pat)
152
+ if pat.respond_to? :to_ary
153
+ exclude(*pat.to_ary)
154
+ else
155
+ @exclude_patterns << Rake.from_pathname(pat)
156
+ end
153
157
  end
154
158
  @exclude_procs << block if block_given?
155
159
  resolve_exclude unless @pending
@@ -190,7 +194,7 @@ module Rake
190
194
  result = @items * other
191
195
  case result
192
196
  when Array
193
- FileList.new.import(result)
197
+ self.class.new.import(result)
194
198
  else
195
199
  result
196
200
  end
@@ -215,7 +219,7 @@ module Rake
215
219
 
216
220
  def resolve_add(fn) # :nodoc:
217
221
  case fn
218
- when %r{[*?\[\{]}
222
+ when GLOB_PATTERN
219
223
  add_matching(fn)
220
224
  else
221
225
  self << fn
@@ -236,7 +240,7 @@ module Rake
236
240
  # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
237
241
  #
238
242
  def sub(pat, rep)
239
- inject(FileList.new) { |res, fn| res << fn.sub(pat, rep) }
243
+ inject(self.class.new) { |res, fn| res << fn.sub(pat, rep) }
240
244
  end
241
245
 
242
246
  # Return a new FileList with the results of running +gsub+ against each
@@ -247,7 +251,7 @@ module Rake
247
251
  # => ['lib\\test\\file', 'x\\y']
248
252
  #
249
253
  def gsub(pat, rep)
250
- inject(FileList.new) { |res, fn| res << fn.gsub(pat, rep) }
254
+ inject(self.class.new) { |res, fn| res << fn.gsub(pat, rep) }
251
255
  end
252
256
 
253
257
  # Same as +sub+ except that the original file list is modified.
@@ -265,8 +269,8 @@ module Rake
265
269
  # Apply the pathmap spec to each of the included file names, returning a
266
270
  # new file list with the modified paths. (See String#pathmap for
267
271
  # details.)
268
- def pathmap(spec=nil)
269
- collect { |fn| fn.pathmap(spec) }
272
+ def pathmap(spec=nil, &block)
273
+ collect { |fn| fn.pathmap(spec, &block) }
270
274
  end
271
275
 
272
276
  # Return a new FileList with <tt>String#ext</tt> method applied to
@@ -277,7 +281,7 @@ module Rake
277
281
  # array.collect { |item| item.ext(newext) }
278
282
  #
279
283
  # +ext+ is a user added method for the Array class.
280
- def ext(newext='')
284
+ def ext(newext="")
281
285
  collect { |fn| fn.ext(newext) }
282
286
  end
283
287
 
@@ -290,7 +294,7 @@ module Rake
290
294
  matched = 0
291
295
  each do |fn|
292
296
  begin
293
- open(fn, "r", *options) do |inf|
297
+ File.open(fn, "r", *options) do |inf|
294
298
  count = 0
295
299
  inf.each do |line|
296
300
  count += 1
@@ -314,14 +318,14 @@ module Rake
314
318
  # Return a new file list that only contains file names from the current
315
319
  # file list that exist on the file system.
316
320
  def existing
317
- select { |fn| File.exist?(fn) }
321
+ select { |fn| File.exist?(fn) }.uniq
318
322
  end
319
323
 
320
324
  # Modify the current file list so that it contains only file name that
321
325
  # exist on the file system.
322
326
  def existing!
323
327
  resolve
324
- @items = @items.select { |fn| File.exist?(fn) }
328
+ @items = @items.select { |fn| File.exist?(fn) }.uniq
325
329
  self
326
330
  end
327
331
 
@@ -331,20 +335,20 @@ module Rake
331
335
  resolve
332
336
  result = @items.partition(&block)
333
337
  [
334
- FileList.new.import(result[0]),
335
- FileList.new.import(result[1]),
338
+ self.class.new.import(result[0]),
339
+ self.class.new.import(result[1]),
336
340
  ]
337
341
  end
338
342
 
339
343
  # Convert a FileList to a string by joining all elements with a space.
340
344
  def to_s
341
345
  resolve
342
- self.join(' ')
346
+ self.join(" ")
343
347
  end
344
348
 
345
349
  # Add matching glob patterns.
346
350
  def add_matching(pattern)
347
- FileList.glob(pattern).each do |fn|
351
+ self.class.glob(pattern).each do |fn|
348
352
  self << fn unless excluded_from_list?(fn)
349
353
  end
350
354
  end
@@ -362,8 +366,11 @@ module Rake
362
366
  case pat
363
367
  when Regexp
364
368
  fn =~ pat
365
- when /[*?]/
366
- File.fnmatch?(pat, fn, File::FNM_PATHNAME)
369
+ when GLOB_PATTERN
370
+ flags = File::FNM_PATHNAME
371
+ # Ruby <= 1.9.3 does not support File::FNM_EXTGLOB
372
+ flags |= File::FNM_EXTGLOB if defined? File::FNM_EXTGLOB
373
+ File.fnmatch?(pat, fn, flags)
367
374
  else
368
375
  fn == pat
369
376
  end
@@ -378,7 +385,7 @@ module Rake
378
385
  /~$/
379
386
  ]
380
387
  DEFAULT_IGNORE_PROCS = [
381
- proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) }
388
+ proc { |fn| fn =~ /(^|[\/\\])core$/ && !File.directory?(fn) }
382
389
  ]
383
390
 
384
391
  def import(array) # :nodoc:
@@ -410,7 +417,7 @@ module Rake
410
417
  # Yield each file or directory component.
411
418
  def each_dir_parent(dir) # :nodoc:
412
419
  old_length = nil
413
- while dir != '.' && dir.length != old_length
420
+ while dir != "." && dir.length != old_length
414
421
  yield(dir)
415
422
  old_length = dir.length
416
423
  dir = File.dirname(dir)