rake 0.9.2.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/CHANGES +4 -0
  2. data/README.rdoc +10 -20
  3. data/Rakefile +6 -1
  4. data/TODO +1 -0
  5. data/bin/rake +4 -0
  6. data/doc/command_line_usage.rdoc +61 -12
  7. data/doc/release_notes/rake-0.9.2.2.rdoc +55 -0
  8. data/doc/release_notes/rake-0.9.3.rdoc +102 -0
  9. data/install.rb +1 -1
  10. data/lib/rake/application.rb +245 -140
  11. data/lib/rake/backtrace.rb +18 -0
  12. data/lib/rake/clean.rb +1 -1
  13. data/lib/rake/cloneable.rb +7 -16
  14. data/lib/rake/contrib/ftptools.rb +2 -1
  15. data/lib/rake/contrib/sys.rb +7 -6
  16. data/lib/rake/dsl_definition.rb +13 -7
  17. data/lib/rake/ext/module.rb +1 -1
  18. data/lib/rake/ext/string.rb +2 -1
  19. data/lib/rake/ext/time.rb +2 -1
  20. data/lib/rake/file_list.rb +9 -2
  21. data/lib/rake/file_utils_ext.rb +4 -3
  22. data/lib/rake/multi_task.rb +2 -5
  23. data/lib/rake/phony.rb +15 -0
  24. data/lib/rake/private_reader.rb +20 -0
  25. data/lib/rake/promise.rb +99 -0
  26. data/lib/rake/rake_module.rb +8 -0
  27. data/lib/rake/rdoctask.rb +1 -1
  28. data/lib/rake/runtest.rb +2 -1
  29. data/lib/rake/task.rb +29 -7
  30. data/lib/rake/task_arguments.rb +1 -1
  31. data/lib/rake/task_manager.rb +1 -1
  32. data/lib/rake/testtask.rb +8 -1
  33. data/lib/rake/thread_history_display.rb +48 -0
  34. data/lib/rake/thread_pool.rb +155 -0
  35. data/lib/rake/version.rb +6 -4
  36. data/lib/rake.rb +1 -0
  37. data/test/helper.rb +57 -0
  38. data/test/test_private_reader.rb +42 -0
  39. data/test/test_rake_application.rb +12 -1
  40. data/test/test_rake_application_options.rb +114 -4
  41. data/test/test_rake_backtrace.rb +81 -0
  42. data/test/test_rake_directory_task.rb +16 -5
  43. data/test/test_rake_file_task.rb +21 -1
  44. data/test/test_rake_functional.rb +40 -1
  45. data/test/test_rake_multi_task.rb +8 -0
  46. data/test/test_rake_reduce_compat.rb +65 -0
  47. data/test/test_rake_task.rb +50 -1
  48. data/test/test_rake_thread_pool.rb +123 -0
  49. data/test/test_thread_history_display.rb +91 -0
  50. metadata +50 -34
@@ -2,10 +2,15 @@ require 'shellwords'
2
2
  require 'optparse'
3
3
 
4
4
  require 'rake/task_manager'
5
+ require 'rake/file_list'
6
+ require 'rake/thread_pool'
7
+ require 'rake/thread_history_display'
5
8
  require 'rake/win32'
6
9
 
7
10
  module Rake
8
11
 
12
+ CommandLineOptionError = Class.new(StandardError)
13
+
9
14
  ######################################################################
10
15
  # Rake main application object. When invoking +rake+ from the
11
16
  # command line, a Rake::Application object is created and run.
@@ -54,7 +59,7 @@ module Rake
54
59
  #
55
60
  # * Initialize the command line options (+init+).
56
61
  # * Define the tasks (+load_rakefile+).
57
- # * Run the top level tasks (+run_tasks+).
62
+ # * Run the top level tasks (+top_level+).
58
63
  #
59
64
  # If you wish to build a custom rake command, you should call
60
65
  # +init+ on your application. Then define any tasks. Finally,
@@ -85,7 +90,7 @@ module Rake
85
90
 
86
91
  # Run the top level tasks of a Rake application.
87
92
  def top_level
88
- standard_exception_handling do
93
+ run_with_threads do
89
94
  if options.show_tasks
90
95
  display_tasks_and_comments
91
96
  elsif options.show_prereqs
@@ -96,6 +101,21 @@ module Rake
96
101
  end
97
102
  end
98
103
 
104
+ # Run the given block with the thread startup and shutdown.
105
+ def run_with_threads
106
+ thread_pool.gather_history if options.job_stats == :history
107
+
108
+ yield
109
+
110
+ thread_pool.join
111
+ if options.job_stats
112
+ stats = thread_pool.statistics
113
+ puts "Maximum active threads: #{stats[:max_active_threads]}"
114
+ puts "Total threads in play: #{stats[:total_threads_in_play]}"
115
+ end
116
+ ThreadHistoryDisplay.new(thread_pool.history).show if options.job_stats == :history
117
+ end
118
+
99
119
  # Add a loader to handle imported files ending in the extension
100
120
  # +ext+.
101
121
  def add_loader(ext, loader)
@@ -108,6 +128,11 @@ module Rake
108
128
  @options ||= OpenStruct.new
109
129
  end
110
130
 
131
+ # Return the thread pool used for multithreaded processing.
132
+ def thread_pool # :nodoc:
133
+ @thread_pool ||= ThreadPool.new(options.thread_pool_size||FIXNUM_MAX)
134
+ end
135
+
111
136
  # private ----------------------------------------------------------------
112
137
 
113
138
  def invoke_task(task_string)
@@ -146,15 +171,15 @@ module Rake
146
171
 
147
172
  # Display the error message that caused the exception.
148
173
  def display_error_message(ex)
149
- $stderr.puts "#{name} aborted!"
150
- $stderr.puts ex.message
151
- if options.trace
152
- $stderr.puts ex.backtrace.join("\n")
174
+ trace "#{name} aborted!"
175
+ trace ex.message
176
+ if options.backtrace
177
+ trace ex.backtrace.join("\n")
153
178
  else
154
- $stderr.puts rakefile_location(ex.backtrace)
179
+ trace Backtrace.collapse(ex.backtrace)
155
180
  end
156
- $stderr.puts "Tasks: #{ex.chain}" if has_chain?(ex)
157
- $stderr.puts "(See full trace by running task with --trace)" unless options.trace
181
+ trace "Tasks: #{ex.chain}" if has_chain?(ex)
182
+ trace "(See full trace by running task with --trace)" unless options.backtrace
158
183
  end
159
184
 
160
185
  # Warn about deprecated usage.
@@ -180,7 +205,7 @@ module Rake
180
205
  def have_rakefile
181
206
  @rakefiles.each do |fn|
182
207
  if File.exist?(fn)
183
- others = Dir.glob(fn, File::FNM_CASEFOLD)
208
+ others = FileList.glob(fn, File::FNM_CASEFOLD)
184
209
  return others.size == 1 ? others.first : fn
185
210
  elsif fn == ''
186
211
  return fn
@@ -208,7 +233,7 @@ module Rake
208
233
  # Display the tasks and comments.
209
234
  def display_tasks_and_comments
210
235
  displayable_tasks = tasks.select { |t|
211
- t.comment && t.name =~ options.show_task_pattern
236
+ (options.show_all_tasks || t.comment) && t.name =~ options.show_task_pattern
212
237
  }
213
238
  case options.show_tasks
214
239
  when :tasks
@@ -222,7 +247,8 @@ module Rake
222
247
  when :describe
223
248
  displayable_tasks.each do |t|
224
249
  puts "#{name} #{t.name_with_args}"
225
- t.full_comment.split("\n").each do |line|
250
+ comment = t.full_comment || ""
251
+ comment.split("\n").each do |line|
226
252
  puts " #{line}"
227
253
  end
228
254
  puts
@@ -271,7 +297,9 @@ module Rake
271
297
  end
272
298
 
273
299
  def truncate(string, width)
274
- if string.length <= width
300
+ if string.nil?
301
+ ""
302
+ elsif string.length <= width
275
303
  string
276
304
  else
277
305
  ( string[0, width-3] || "" ) + "..."
@@ -286,141 +314,214 @@ module Rake
286
314
  end
287
315
  end
288
316
 
317
+ def trace(*str)
318
+ options.trace_output ||= $stderr
319
+ options.trace_output.puts(*str)
320
+ end
321
+
322
+ def sort_options(options)
323
+ options.sort_by { |opt|
324
+ opt.select { |o| o =~ /^-/ }.map { |o| o.downcase }.sort.reverse
325
+ }
326
+ end
327
+ private :sort_options
328
+
289
329
  # A list of all the standard options used in rake, suitable for
290
330
  # passing to OptionParser.
291
331
  def standard_rake_options
292
- [
293
- ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
294
- lambda { |value|
295
- require 'rake/classic_namespace'
296
- options.classic_namespace = true
297
- }
298
- ],
299
- ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
300
- lambda { |value|
301
- options.show_tasks = :describe
302
- options.show_task_pattern = Regexp.new(value || '')
303
- TaskManager.record_task_metadata = true
304
- }
305
- ],
306
- ['--dry-run', '-n', "Do a dry run without executing actions.",
307
- lambda { |value|
308
- Rake.verbose(true)
309
- Rake.nowrite(true)
310
- options.dryrun = true
311
- options.trace = true
312
- }
313
- ],
314
- ['--execute', '-e CODE', "Execute some Ruby code and exit.",
315
- lambda { |value|
316
- eval(value)
317
- exit
318
- }
319
- ],
320
- ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
321
- lambda { |value|
322
- puts eval(value)
323
- exit
324
- }
325
- ],
326
- ['--execute-continue', '-E CODE',
327
- "Execute some Ruby code, then continue with normal task processing.",
328
- lambda { |value| eval(value) }
329
- ],
330
- ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
331
- lambda { |value| $:.push(value) }
332
- ],
333
- ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
334
- lambda { |value| options.nosearch = true }
335
- ],
336
- ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
337
- lambda { |value| options.show_prereqs = true }
338
- ],
339
- ['--quiet', '-q', "Do not log messages to standard output.",
340
- lambda { |value| Rake.verbose(false) }
341
- ],
342
- ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
343
- lambda { |value|
344
- value ||= ''
345
- @rakefiles.clear
346
- @rakefiles << value
347
- }
348
- ],
349
- ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
350
- "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
351
- # HACK Use File::PATH_SEPARATOR
352
- lambda { |value| options.rakelib = value.split(':') }
353
- ],
354
- ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
355
- lambda { |value|
356
- begin
357
- require value
358
- rescue LoadError => ex
332
+ sort_options(
333
+ [
334
+ ['--all', '-A', "Show all tasks, even uncommented ones",
335
+ lambda { |value|
336
+ options.show_all_tasks = value
337
+ }
338
+ ],
339
+ ['--backtrace [OUT]', "Enable full backtrace. OUT can be stderr (default) or stdout.",
340
+ lambda { |value|
341
+ options.backtrace = true
342
+ select_trace_output(options, 'backtrace', value)
343
+ }
344
+ ],
345
+ ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
346
+ lambda { |value|
347
+ require 'rake/classic_namespace'
348
+ options.classic_namespace = true
349
+ }
350
+ ],
351
+ ['--comments', "Show commented tasks only",
352
+ lambda { |value|
353
+ options.show_all_tasks = !value
354
+ }
355
+ ],
356
+ ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
357
+ lambda { |value|
358
+ select_tasks_to_show(options, :describe, value)
359
+ }
360
+ ],
361
+ ['--dry-run', '-n', "Do a dry run without executing actions.",
362
+ lambda { |value|
363
+ Rake.verbose(true)
364
+ Rake.nowrite(true)
365
+ options.dryrun = true
366
+ options.trace = true
367
+ }
368
+ ],
369
+ ['--execute', '-e CODE', "Execute some Ruby code and exit.",
370
+ lambda { |value|
371
+ eval(value)
372
+ exit
373
+ }
374
+ ],
375
+ ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
376
+ lambda { |value|
377
+ puts eval(value)
378
+ exit
379
+ }
380
+ ],
381
+ ['--execute-continue', '-E CODE',
382
+ "Execute some Ruby code, then continue with normal task processing.",
383
+ lambda { |value| eval(value) }
384
+ ],
385
+ ['--jobs', '-j [NUMBER]',
386
+ "Specifies the maximum number of tasks to execute in parallel. (default:2)",
387
+ lambda { |value| options.thread_pool_size = [(value || 2).to_i,2].max }
388
+ ],
389
+ ['--job-stats [LEVEL]',
390
+ "Display job statistics. LEVEL=history displays a complete job list",
391
+ lambda { |value|
392
+ if value =~ /^history/i
393
+ options.job_stats = :history
394
+ else
395
+ options.job_stats = true
396
+ end
397
+ }
398
+ ],
399
+ ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
400
+ lambda { |value| $:.push(value) }
401
+ ],
402
+ ['--multitask', '-m', "Treat all tasks as multitasks.",
403
+ lambda { |value| options.always_multitask = true }
404
+ ],
405
+ ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
406
+ lambda { |value| options.nosearch = true }
407
+ ],
408
+ ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
409
+ lambda { |value| options.show_prereqs = true }
410
+ ],
411
+ ['--quiet', '-q', "Do not log messages to standard output.",
412
+ lambda { |value| Rake.verbose(false) }
413
+ ],
414
+ ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
415
+ lambda { |value|
416
+ value ||= ''
417
+ @rakefiles.clear
418
+ @rakefiles << value
419
+ }
420
+ ],
421
+ ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
422
+ "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
423
+ lambda { |value| options.rakelib = value.split(File::PATH_SEPARATOR) }
424
+ ],
425
+ ['--reduce-compat', "Remove DSL in Object; remove Module#const_missing which defines ::Task etc.",
426
+ # Load-time option.
427
+ # Handled in bin/rake where Rake::REDUCE_COMPAT is defined (or not).
428
+ lambda { |_| }
429
+ ],
430
+ ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
431
+ lambda { |value|
359
432
  begin
360
- rake_require value
361
- rescue LoadError
362
- raise ex
433
+ require value
434
+ rescue LoadError => ex
435
+ begin
436
+ rake_require value
437
+ rescue LoadError
438
+ raise ex
439
+ end
363
440
  end
364
- end
365
- }
366
- ],
367
- ['--rules', "Trace the rules resolution.",
368
- lambda { |value| options.trace_rules = true }
369
- ],
370
- ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
371
- lambda { |value|
372
- Rake.verbose(false)
373
- options.silent = true
374
- }
375
- ],
376
- ['--system', '-g',
377
- "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
378
- lambda { |value| options.load_system = true }
379
- ],
380
- ['--no-system', '--nosystem', '-G',
381
- "Use standard project Rakefile search paths, ignore system wide rakefiles.",
382
- lambda { |value| options.ignore_system = true }
383
- ],
384
- ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
385
- lambda { |value|
386
- options.show_tasks = :tasks
387
- options.show_task_pattern = Regexp.new(value || '')
388
- Rake::TaskManager.record_task_metadata = true
389
- }
390
- ],
391
- ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
392
- lambda { |value|
393
- options.trace = true
394
- Rake.verbose(true)
395
- }
396
- ],
397
- ['--verbose', '-v', "Log message to standard output.",
398
- lambda { |value| Rake.verbose(true) }
399
- ],
400
- ['--version', '-V', "Display the program version.",
401
- lambda { |value|
402
- puts "rake, version #{RAKEVERSION}"
403
- exit
404
- }
405
- ],
406
- ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
407
- lambda { |value|
408
- options.show_tasks = :lines
409
- options.show_task_pattern = Regexp.new(value || '')
410
- Rake::TaskManager.record_task_metadata = true
411
- }
412
- ],
413
- ['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
414
- lambda { |value|
415
- options.ignore_deprecate = true
416
- }
417
- ],
418
- ]
441
+ }
442
+ ],
443
+ ['--rules', "Trace the rules resolution.",
444
+ lambda { |value| options.trace_rules = true }
445
+ ],
446
+ ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
447
+ lambda { |value|
448
+ Rake.verbose(false)
449
+ options.silent = true
450
+ }
451
+ ],
452
+ ['--suppress-backtrace PATTERN', "Suppress backtrace lines matching regexp PATTERN. Ignored if --trace is on.",
453
+ lambda { |value|
454
+ options.suppress_backtrace_pattern = Regexp.new(value)
455
+ }
456
+ ],
457
+ ['--system', '-g',
458
+ "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
459
+ lambda { |value| options.load_system = true }
460
+ ],
461
+ ['--no-system', '--nosystem', '-G',
462
+ "Use standard project Rakefile search paths, ignore system wide rakefiles.",
463
+ lambda { |value| options.ignore_system = true }
464
+ ],
465
+ ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
466
+ lambda { |value|
467
+ select_tasks_to_show(options, :tasks, value)
468
+ }
469
+ ],
470
+ ['--trace', '-t [OUT]', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
471
+ lambda { |value|
472
+ options.trace = true
473
+ options.backtrace = true
474
+ select_trace_output(options, 'trace', value)
475
+ Rake.verbose(true)
476
+ }
477
+ ],
478
+ ['--verbose', '-v', "Log message to standard output.",
479
+ lambda { |value| Rake.verbose(true) }
480
+ ],
481
+ ['--version', '-V', "Display the program version.",
482
+ lambda { |value|
483
+ puts "rake, version #{RAKEVERSION}"
484
+ exit
485
+ }
486
+ ],
487
+ ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
488
+ lambda { |value|
489
+ select_tasks_to_show(options, :lines, value)
490
+ options.show_all_tasks = true
491
+ }
492
+ ],
493
+ ['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
494
+ lambda { |value|
495
+ options.ignore_deprecate = true
496
+ }
497
+ ],
498
+ ])
499
+ end
500
+
501
+ def select_tasks_to_show(options, show_tasks, value)
502
+ options.show_tasks = show_tasks
503
+ options.show_task_pattern = Regexp.new(value || '')
504
+ Rake::TaskManager.record_task_metadata = true
505
+ end
506
+ private :select_tasks_to_show
507
+
508
+ def select_trace_output(options, trace_option, value)
509
+ value = value.strip unless value.nil?
510
+ case value
511
+ when 'stdout'
512
+ options.trace_output = $stdout
513
+ when 'stderr', nil
514
+ options.trace_output = $stderr
515
+ else
516
+ fail CommandLineOptionError, "Unrecognized --#{trace_option} option '#{value}'"
517
+ end
419
518
  end
519
+ private :select_trace_output
420
520
 
421
521
  # Read and handle the command line options.
422
522
  def handle_options
423
523
  options.rakelib = ['rakelib']
524
+ options.trace_output = $stderr
424
525
 
425
526
  OptionParser.new do |opts|
426
527
  opts.banner = "rake [-f rakefile] {options} targets..."
@@ -509,7 +610,7 @@ module Rake
509
610
  end
510
611
 
511
612
  def glob(path, &block)
512
- Dir[path.gsub("\\", '/')].each(&block)
613
+ FileList.glob(path.gsub("\\", '/')).each(&block)
513
614
  end
514
615
  private :glob
515
616
 
@@ -583,7 +684,7 @@ module Rake
583
684
  @const_warning = true
584
685
  end
585
686
 
586
- def rakefile_location backtrace = caller
687
+ def rakefile_location(backtrace=caller)
587
688
  backtrace.map { |t| t[/([^:]+):/,1] }
588
689
 
589
690
  re = /^#{@rakefile}$/
@@ -591,5 +692,9 @@ module Rake
591
692
 
592
693
  backtrace.find { |str| str =~ re } || ''
593
694
  end
695
+
696
+ private
697
+ FIXNUM_MAX = (2**(0.size * 8 - 2) - 1) # :nodoc:
698
+
594
699
  end
595
700
  end
@@ -0,0 +1,18 @@
1
+ module Rake
2
+ module Backtrace
3
+ SUPPRESSED_PATHS =
4
+ RbConfig::CONFIG.values_at(*RbConfig::CONFIG.
5
+ keys.grep(/(prefix|libdir)/)) + [
6
+ File.join(File.dirname(__FILE__), ".."),
7
+ ].map { |f| Regexp.quote(File.expand_path(f)) }
8
+ SUPPRESSED_PATHS.reject! { |s| s.nil? || s =~ /^ *$/ }
9
+
10
+ SUPPRESS_PATTERN = %r!(\A#{SUPPRESSED_PATHS.join('|')}|bin/rake:\d+)!i
11
+
12
+ def self.collapse(backtrace)
13
+ pattern = Rake.application.options.suppress_backtrace_pattern ||
14
+ SUPPRESS_PATTERN
15
+ backtrace.reject { |elem| elem =~ pattern }
16
+ end
17
+ end
18
+ end
data/lib/rake/clean.rb CHANGED
@@ -16,7 +16,7 @@ require 'rake'
16
16
  # :stopdoc:
17
17
  CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
18
18
  CLEAN.clear_exclude.exclude { |fn|
19
- fn.pathmap("%f") == 'core' && File.directory?(fn)
19
+ fn.pathmap("%f").downcase == 'core' && File.directory?(fn)
20
20
  }
21
21
 
22
22
  desc "Remove any temporary products."
@@ -3,23 +3,14 @@ module Rake
3
3
  # Mixin for creating easily cloned objects.
4
4
  #
5
5
  module Cloneable
6
- # Clone an object by making a new object and setting all the instance
7
- # variables to the same values.
8
- def dup
9
- sibling = self.class.new
10
- instance_variables.each do |ivar|
11
- value = self.instance_variable_get(ivar)
12
- new_value = value.clone rescue value
13
- sibling.instance_variable_set(ivar, new_value)
6
+ # The hook that invoked by 'clone' and 'dup' methods.
7
+ def initialize_copy(source)
8
+ super
9
+ source.instance_variables.each do |var|
10
+ src_value = source.instance_variable_get(var)
11
+ value = src_value.clone rescue src_value
12
+ instance_variable_set(var, value)
14
13
  end
15
- sibling.taint if tainted?
16
- sibling
17
- end
18
-
19
- def clone
20
- sibling = dup
21
- sibling.freeze if frozen?
22
- sibling
23
14
  end
24
15
  end
25
16
  end
@@ -5,6 +5,7 @@
5
5
 
6
6
  require 'date'
7
7
  require 'net/ftp'
8
+ require 'rake/file_list'
8
9
 
9
10
  module Rake # :nodoc:
10
11
 
@@ -127,7 +128,7 @@ module Rake # :nodoc:
127
128
  # Upload all files matching +wildcard+ to the uploader's root
128
129
  # path.
129
130
  def upload_files(wildcard)
130
- Dir[wildcard].each do |fn|
131
+ FileList.glob(wildcard).each do |fn|
131
132
  upload(fn)
132
133
  end
133
134
  end
@@ -10,6 +10,7 @@ begin
10
10
  rescue LoadError
11
11
  end
12
12
  require 'rbconfig'
13
+ require 'rake/file_list'
13
14
 
14
15
  ######################################################################
15
16
  # Sys provides a number of file manipulation tools for the convenience
@@ -27,7 +28,7 @@ module Sys
27
28
  # Install all the files matching +wildcard+ into the +dest_dir+
28
29
  # directory. The permission mode is set to +mode+.
29
30
  def install(wildcard, dest_dir, mode)
30
- Dir[wildcard].each do |fn|
31
+ FileList.glob(wildcard).each do |fn|
31
32
  File.install(fn, dest_dir, mode, $verbose)
32
33
  end
33
34
  end
@@ -81,7 +82,7 @@ module Sys
81
82
  # recursively delete directories.
82
83
  def delete(*wildcards)
83
84
  wildcards.each do |wildcard|
84
- Dir[wildcard].each do |fn|
85
+ FileList.glob(wildcard).each do |fn|
85
86
  if File.directory?(fn)
86
87
  log "Deleting directory #{fn}"
87
88
  Dir.delete(fn)
@@ -96,10 +97,10 @@ module Sys
96
97
  # Recursively delete all files and directories matching +wildcard+.
97
98
  def delete_all(*wildcards)
98
99
  wildcards.each do |wildcard|
99
- Dir[wildcard].each do |fn|
100
+ FileList.glob(wildcard).each do |fn|
100
101
  next if ! File.exist?(fn)
101
102
  if File.directory?(fn)
102
- Dir["#{fn}/*"].each do |subfn|
103
+ FileList.glob("#{fn}/*").each do |subfn|
103
104
  next if subfn=='.' || subfn=='..'
104
105
  delete_all(subfn)
105
106
  end
@@ -161,7 +162,7 @@ module Sys
161
162
  # Perform a block with each file matching a set of wildcards.
162
163
  def for_files(*wildcards)
163
164
  wildcards.each do |wildcard|
164
- Dir[wildcard].each do |fn|
165
+ FileList.glob(wildcard).each do |fn|
165
166
  yield(fn)
166
167
  end
167
168
  end
@@ -172,7 +173,7 @@ module Sys
172
173
  private # ----------------------------------------------------------
173
174
 
174
175
  def for_matching_files(wildcard, dest_dir)
175
- Dir[wildcard].each do |fn|
176
+ FileList.glob(wildcard).each do |fn|
176
177
  dest_file = File.join(dest_dir, fn)
177
178
  parent = File.dirname(dest_file)
178
179
  makedirs(parent) if ! File.directory?(parent)