rake 0.9.2.2 → 0.9.3

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 -8
  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 +244 -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 +6 -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 +2 -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 +13 -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 +15 -0
  27. data/lib/rake/rdoctask.rb +1 -1
  28. data/lib/rake/runtest.rb +1 -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 +5 -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 +30 -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 +22 -0
  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 +53 -37
@@ -2,10 +2,14 @@ require 'shellwords'
2
2
  require 'optparse'
3
3
 
4
4
  require 'rake/task_manager'
5
+ require 'rake/thread_pool'
6
+ require 'rake/thread_history_display'
5
7
  require 'rake/win32'
6
8
 
7
9
  module Rake
8
10
 
11
+ CommandLineOptionError = Class.new(StandardError)
12
+
9
13
  ######################################################################
10
14
  # Rake main application object. When invoking +rake+ from the
11
15
  # command line, a Rake::Application object is created and run.
@@ -54,7 +58,7 @@ module Rake
54
58
  #
55
59
  # * Initialize the command line options (+init+).
56
60
  # * Define the tasks (+load_rakefile+).
57
- # * Run the top level tasks (+run_tasks+).
61
+ # * Run the top level tasks (+top_level+).
58
62
  #
59
63
  # If you wish to build a custom rake command, you should call
60
64
  # +init+ on your application. Then define any tasks. Finally,
@@ -85,7 +89,7 @@ module Rake
85
89
 
86
90
  # Run the top level tasks of a Rake application.
87
91
  def top_level
88
- standard_exception_handling do
92
+ run_with_threads do
89
93
  if options.show_tasks
90
94
  display_tasks_and_comments
91
95
  elsif options.show_prereqs
@@ -96,6 +100,21 @@ module Rake
96
100
  end
97
101
  end
98
102
 
103
+ # Run the given block with the thread startup and shutdown.
104
+ def run_with_threads
105
+ thread_pool.gather_history if options.job_stats == :history
106
+
107
+ yield
108
+
109
+ thread_pool.join
110
+ if options.job_stats
111
+ stats = thread_pool.statistics
112
+ puts "Maximum active threads: #{stats[:max_active_threads]}"
113
+ puts "Total threads in play: #{stats[:total_threads_in_play]}"
114
+ end
115
+ ThreadHistoryDisplay.new(thread_pool.history).show if options.job_stats == :history
116
+ end
117
+
99
118
  # Add a loader to handle imported files ending in the extension
100
119
  # +ext+.
101
120
  def add_loader(ext, loader)
@@ -108,6 +127,11 @@ module Rake
108
127
  @options ||= OpenStruct.new
109
128
  end
110
129
 
130
+ # Return the thread pool used for multithreaded processing.
131
+ def thread_pool # :nodoc:
132
+ @thread_pool ||= ThreadPool.new(options.thread_pool_size||FIXNUM_MAX)
133
+ end
134
+
111
135
  # private ----------------------------------------------------------------
112
136
 
113
137
  def invoke_task(task_string)
@@ -146,15 +170,15 @@ module Rake
146
170
 
147
171
  # Display the error message that caused the exception.
148
172
  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")
173
+ trace "#{name} aborted!"
174
+ trace ex.message
175
+ if options.backtrace
176
+ trace ex.backtrace.join("\n")
153
177
  else
154
- $stderr.puts rakefile_location(ex.backtrace)
178
+ trace Backtrace.collapse(ex.backtrace)
155
179
  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
180
+ trace "Tasks: #{ex.chain}" if has_chain?(ex)
181
+ trace "(See full trace by running task with --trace)" unless options.backtrace
158
182
  end
159
183
 
160
184
  # Warn about deprecated usage.
@@ -180,7 +204,7 @@ module Rake
180
204
  def have_rakefile
181
205
  @rakefiles.each do |fn|
182
206
  if File.exist?(fn)
183
- others = Dir.glob(fn, File::FNM_CASEFOLD)
207
+ others = Rake.glob(fn, File::FNM_CASEFOLD)
184
208
  return others.size == 1 ? others.first : fn
185
209
  elsif fn == ''
186
210
  return fn
@@ -208,7 +232,7 @@ module Rake
208
232
  # Display the tasks and comments.
209
233
  def display_tasks_and_comments
210
234
  displayable_tasks = tasks.select { |t|
211
- t.comment && t.name =~ options.show_task_pattern
235
+ (options.show_all_tasks || t.comment) && t.name =~ options.show_task_pattern
212
236
  }
213
237
  case options.show_tasks
214
238
  when :tasks
@@ -222,7 +246,8 @@ module Rake
222
246
  when :describe
223
247
  displayable_tasks.each do |t|
224
248
  puts "#{name} #{t.name_with_args}"
225
- t.full_comment.split("\n").each do |line|
249
+ comment = t.full_comment || ""
250
+ comment.split("\n").each do |line|
226
251
  puts " #{line}"
227
252
  end
228
253
  puts
@@ -271,7 +296,9 @@ module Rake
271
296
  end
272
297
 
273
298
  def truncate(string, width)
274
- if string.length <= width
299
+ if string.nil?
300
+ ""
301
+ elsif string.length <= width
275
302
  string
276
303
  else
277
304
  ( string[0, width-3] || "" ) + "..."
@@ -286,141 +313,214 @@ module Rake
286
313
  end
287
314
  end
288
315
 
316
+ def trace(*str)
317
+ options.trace_output ||= $stderr
318
+ options.trace_output.puts(*str)
319
+ end
320
+
321
+ def sort_options(options)
322
+ options.sort_by { |opt|
323
+ opt.select { |o| o =~ /^-/ }.map { |o| o.downcase }.sort.reverse
324
+ }
325
+ end
326
+ private :sort_options
327
+
289
328
  # A list of all the standard options used in rake, suitable for
290
329
  # passing to OptionParser.
291
330
  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
331
+ sort_options(
332
+ [
333
+ ['--all', '-A', "Show all tasks, even uncommented ones",
334
+ lambda { |value|
335
+ options.show_all_tasks = value
336
+ }
337
+ ],
338
+ ['--backtrace [OUT]', "Enable full backtrace. OUT can be stderr (default) or stdout.",
339
+ lambda { |value|
340
+ options.backtrace = true
341
+ select_trace_output(options, 'backtrace', value)
342
+ }
343
+ ],
344
+ ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
345
+ lambda { |value|
346
+ require 'rake/classic_namespace'
347
+ options.classic_namespace = true
348
+ }
349
+ ],
350
+ ['--comments', "Show commented tasks only",
351
+ lambda { |value|
352
+ options.show_all_tasks = !value
353
+ }
354
+ ],
355
+ ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
356
+ lambda { |value|
357
+ select_tasks_to_show(options, :describe, value)
358
+ }
359
+ ],
360
+ ['--dry-run', '-n', "Do a dry run without executing actions.",
361
+ lambda { |value|
362
+ Rake.verbose(true)
363
+ Rake.nowrite(true)
364
+ options.dryrun = true
365
+ options.trace = true
366
+ }
367
+ ],
368
+ ['--execute', '-e CODE', "Execute some Ruby code and exit.",
369
+ lambda { |value|
370
+ eval(value)
371
+ exit
372
+ }
373
+ ],
374
+ ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
375
+ lambda { |value|
376
+ puts eval(value)
377
+ exit
378
+ }
379
+ ],
380
+ ['--execute-continue', '-E CODE',
381
+ "Execute some Ruby code, then continue with normal task processing.",
382
+ lambda { |value| eval(value) }
383
+ ],
384
+ ['--jobs', '-j [NUMBER]',
385
+ "Specifies the maximum number of tasks to execute in parallel. (default:2)",
386
+ lambda { |value| options.thread_pool_size = [(value || 2).to_i,2].max }
387
+ ],
388
+ ['--job-stats [LEVEL]',
389
+ "Display job statistics. LEVEL=history displays a complete job list",
390
+ lambda { |value|
391
+ if value =~ /^history/i
392
+ options.job_stats = :history
393
+ else
394
+ options.job_stats = true
395
+ end
396
+ }
397
+ ],
398
+ ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
399
+ lambda { |value| $:.push(value) }
400
+ ],
401
+ ['--multitask', '-m', "Treat all tasks as multitasks.",
402
+ lambda { |value| options.always_multitask = true }
403
+ ],
404
+ ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
405
+ lambda { |value| options.nosearch = true }
406
+ ],
407
+ ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
408
+ lambda { |value| options.show_prereqs = true }
409
+ ],
410
+ ['--quiet', '-q', "Do not log messages to standard output.",
411
+ lambda { |value| Rake.verbose(false) }
412
+ ],
413
+ ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
414
+ lambda { |value|
415
+ value ||= ''
416
+ @rakefiles.clear
417
+ @rakefiles << value
418
+ }
419
+ ],
420
+ ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
421
+ "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
422
+ lambda { |value| options.rakelib = value.split(File::PATH_SEPARATOR) }
423
+ ],
424
+ ['--reduce-compat', "Remove DSL in Object; remove Module#const_missing which defines ::Task etc.",
425
+ # Load-time option.
426
+ # Handled in bin/rake where Rake::REDUCE_COMPAT is defined (or not).
427
+ lambda { |_| }
428
+ ],
429
+ ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
430
+ lambda { |value|
359
431
  begin
360
- rake_require value
361
- rescue LoadError
362
- raise ex
432
+ require value
433
+ rescue LoadError => ex
434
+ begin
435
+ rake_require value
436
+ rescue LoadError
437
+ raise ex
438
+ end
363
439
  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
- ]
440
+ }
441
+ ],
442
+ ['--rules', "Trace the rules resolution.",
443
+ lambda { |value| options.trace_rules = true }
444
+ ],
445
+ ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
446
+ lambda { |value|
447
+ Rake.verbose(false)
448
+ options.silent = true
449
+ }
450
+ ],
451
+ ['--suppress-backtrace PATTERN', "Suppress backtrace lines matching regexp PATTERN. Ignored if --trace is on.",
452
+ lambda { |value|
453
+ options.suppress_backtrace_pattern = Regexp.new(value)
454
+ }
455
+ ],
456
+ ['--system', '-g',
457
+ "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
458
+ lambda { |value| options.load_system = true }
459
+ ],
460
+ ['--no-system', '--nosystem', '-G',
461
+ "Use standard project Rakefile search paths, ignore system wide rakefiles.",
462
+ lambda { |value| options.ignore_system = true }
463
+ ],
464
+ ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
465
+ lambda { |value|
466
+ select_tasks_to_show(options, :tasks, value)
467
+ }
468
+ ],
469
+ ['--trace', '-t [OUT]', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
470
+ lambda { |value|
471
+ options.trace = true
472
+ options.backtrace = true
473
+ select_trace_output(options, 'trace', value)
474
+ Rake.verbose(true)
475
+ }
476
+ ],
477
+ ['--verbose', '-v', "Log message to standard output.",
478
+ lambda { |value| Rake.verbose(true) }
479
+ ],
480
+ ['--version', '-V', "Display the program version.",
481
+ lambda { |value|
482
+ puts "rake, version #{RAKEVERSION}"
483
+ exit
484
+ }
485
+ ],
486
+ ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
487
+ lambda { |value|
488
+ select_tasks_to_show(options, :lines, value)
489
+ options.show_all_tasks = true
490
+ }
491
+ ],
492
+ ['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
493
+ lambda { |value|
494
+ options.ignore_deprecate = true
495
+ }
496
+ ],
497
+ ])
498
+ end
499
+
500
+ def select_tasks_to_show(options, show_tasks, value)
501
+ options.show_tasks = show_tasks
502
+ options.show_task_pattern = Regexp.new(value || '')
503
+ Rake::TaskManager.record_task_metadata = true
504
+ end
505
+ private :select_tasks_to_show
506
+
507
+ def select_trace_output(options, trace_option, value)
508
+ value = value.strip unless value.nil?
509
+ case value
510
+ when 'stdout'
511
+ options.trace_output = $stdout
512
+ when 'stderr', nil
513
+ options.trace_output = $stderr
514
+ else
515
+ fail CommandLineOptionError, "Unrecognized --#{trace_option} option '#{value}'"
516
+ end
419
517
  end
518
+ private :select_trace_output
420
519
 
421
520
  # Read and handle the command line options.
422
521
  def handle_options
423
522
  options.rakelib = ['rakelib']
523
+ options.trace_output = $stderr
424
524
 
425
525
  OptionParser.new do |opts|
426
526
  opts.banner = "rake [-f rakefile] {options} targets..."
@@ -509,7 +609,7 @@ module Rake
509
609
  end
510
610
 
511
611
  def glob(path, &block)
512
- Dir[path.gsub("\\", '/')].each(&block)
612
+ Rake.glob(path.gsub("\\", '/')).each(&block)
513
613
  end
514
614
  private :glob
515
615
 
@@ -583,7 +683,7 @@ module Rake
583
683
  @const_warning = true
584
684
  end
585
685
 
586
- def rakefile_location backtrace = caller
686
+ def rakefile_location(backtrace=caller)
587
687
  backtrace.map { |t| t[/([^:]+):/,1] }
588
688
 
589
689
  re = /^#{@rakefile}$/
@@ -591,5 +691,9 @@ module Rake
591
691
 
592
692
  backtrace.find { |str| str =~ re } || ''
593
693
  end
694
+
695
+ private
696
+ FIXNUM_MAX = (2**(0.size * 8 - 2) - 1) # :nodoc:
697
+
594
698
  end
595
699
  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
@@ -127,7 +127,8 @@ module Rake # :nodoc:
127
127
  # Upload all files matching +wildcard+ to the uploader's root
128
128
  # path.
129
129
  def upload_files(wildcard)
130
- Dir[wildcard].each do |fn|
130
+ fail "OUCH"
131
+ Rake.glob(wildcard).each do |fn|
131
132
  upload(fn)
132
133
  end
133
134
  end
@@ -27,7 +27,7 @@ module Sys
27
27
  # Install all the files matching +wildcard+ into the +dest_dir+
28
28
  # directory. The permission mode is set to +mode+.
29
29
  def install(wildcard, dest_dir, mode)
30
- Dir[wildcard].each do |fn|
30
+ Rake.glob(wildcard).each do |fn|
31
31
  File.install(fn, dest_dir, mode, $verbose)
32
32
  end
33
33
  end
@@ -81,7 +81,7 @@ module Sys
81
81
  # recursively delete directories.
82
82
  def delete(*wildcards)
83
83
  wildcards.each do |wildcard|
84
- Dir[wildcard].each do |fn|
84
+ Rake.glob(wildcard).each do |fn|
85
85
  if File.directory?(fn)
86
86
  log "Deleting directory #{fn}"
87
87
  Dir.delete(fn)
@@ -96,10 +96,10 @@ module Sys
96
96
  # Recursively delete all files and directories matching +wildcard+.
97
97
  def delete_all(*wildcards)
98
98
  wildcards.each do |wildcard|
99
- Dir[wildcard].each do |fn|
99
+ Rake.glob(wildcard).each do |fn|
100
100
  next if ! File.exist?(fn)
101
101
  if File.directory?(fn)
102
- Dir["#{fn}/*"].each do |subfn|
102
+ Rake.glob("#{fn}/*").each do |subfn|
103
103
  next if subfn=='.' || subfn=='..'
104
104
  delete_all(subfn)
105
105
  end
@@ -161,7 +161,7 @@ module Sys
161
161
  # Perform a block with each file matching a set of wildcards.
162
162
  def for_files(*wildcards)
163
163
  wildcards.each do |wildcard|
164
- Dir[wildcard].each do |fn|
164
+ Rake.glob(wildcard).each do |fn|
165
165
  yield(fn)
166
166
  end
167
167
  end
@@ -172,7 +172,7 @@ module Sys
172
172
  private # ----------------------------------------------------------
173
173
 
174
174
  def for_matching_files(wildcard, dest_dir)
175
- Dir[wildcard].each do |fn|
175
+ Rake.glob(wildcard).each do |fn|
176
176
  dest_file = File.join(dest_dir, fn)
177
177
  parent = File.dirname(dest_file)
178
178
  makedirs(parent) if ! File.directory?(parent)
@@ -52,8 +52,8 @@ module Rake
52
52
 
53
53
  # Declare a file creation task.
54
54
  # (Mainly used for the directory command).
55
- def file_create(args, &block)
56
- Rake::FileCreationTask.define_task(args, &block)
55
+ def file_create(*args, &block)
56
+ Rake::FileCreationTask.define_task(*args, &block)
57
57
  end
58
58
 
59
59
  # Declare a set of files tasks to create the given directories on
@@ -62,12 +62,15 @@ module Rake
62
62
  # Example:
63
63
  # directory "testdata/doc"
64
64
  #
65
- def directory(dir)
65
+ def directory(*args, &block)
66
+ result = file_create(*args, &block)
67
+ dir, _ = *Rake.application.resolve_args(args)
66
68
  Rake.each_dir_parent(dir) do |d|
67
69
  file_create d do |t|
68
70
  mkdir_p t.name if ! File.exist?(t.name)
69
71
  end
70
72
  end
73
+ result
71
74
  end
72
75
 
73
76
  # Declare a task that performs its prerequisites in
@@ -78,8 +81,8 @@ module Rake
78
81
  # Example:
79
82
  # multitask :deploy => [:deploy_gem, :deploy_rdoc]
80
83
  #
81
- def multitask(args, &block)
82
- Rake::MultiTask.define_task(args, &block)
84
+ def multitask(*args, &block)
85
+ Rake::MultiTask.define_task(*args, &block)
83
86
  end
84
87
 
85
88
  # Create a new rake namespace and use it for evaluating the given
@@ -167,10 +170,13 @@ module Rake
167
170
  private :#{name}
168
171
  }, __FILE__, line
169
172
  end
170
- end
173
+ end unless defined? Rake::REDUCE_COMPAT
171
174
 
172
175
  extend FileUtilsExt
173
176
  end
174
177
 
178
+ # Extend the main object with the DSL commands. This allows top-level
179
+ # calls to task, etc. to work from a Rakefile without polluting the
180
+ # object inheritance tree.
175
181
  self.extend Rake::DSL
176
- include Rake::DeprecatedObjectDSL
182
+ include Rake::DeprecatedObjectDSL unless defined? Rake::REDUCE_COMPAT