rake 10.0.4 → 10.1.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/doc/rakefile.rdoc +19 -0
  3. data/lib/rake/alt_system.rb +3 -4
  4. data/lib/rake/application.rb +114 -67
  5. data/lib/rake/backtrace.rb +9 -8
  6. data/lib/rake/contrib/ftptools.rb +6 -18
  7. data/lib/rake/contrib/sys.rb +2 -1
  8. data/lib/rake/dsl_definition.rb +1 -1
  9. data/lib/rake/ext/core.rb +2 -1
  10. data/lib/rake/ext/string.rb +1 -3
  11. data/lib/rake/file_list.rb +14 -14
  12. data/lib/rake/file_task.rb +1 -2
  13. data/lib/rake/file_utils.rb +9 -7
  14. data/lib/rake/file_utils_ext.rb +2 -1
  15. data/lib/rake/gempackagetask.rb +2 -1
  16. data/lib/rake/invocation_chain.rb +2 -0
  17. data/lib/rake/packagetask.rb +11 -6
  18. data/lib/rake/pseudo_status.rb +5 -0
  19. data/lib/rake/rdoctask.rb +2 -1
  20. data/lib/rake/ruby182_test_unit_fix.rb +4 -2
  21. data/lib/rake/runtest.rb +2 -2
  22. data/lib/rake/task.rb +9 -10
  23. data/lib/rake/task_arguments.rb +13 -2
  24. data/lib/rake/task_manager.rb +9 -8
  25. data/lib/rake/tasklib.rb +1 -1
  26. data/lib/rake/testtask.rb +10 -7
  27. data/lib/rake/thread_history_display.rb +1 -1
  28. data/lib/rake/thread_pool.rb +10 -4
  29. data/lib/rake/version.rb +3 -7
  30. data/lib/rake/win32.rb +3 -2
  31. data/test/helper.rb +28 -28
  32. data/test/test_rake_application.rb +14 -12
  33. data/test/test_rake_application_options.rb +7 -5
  34. data/test/test_rake_backtrace.rb +30 -1
  35. data/test/test_rake_definitions.rb +2 -3
  36. data/test/test_rake_file_creation_task.rb +2 -2
  37. data/test/test_rake_file_list.rb +9 -10
  38. data/test/test_rake_file_task.rb +4 -4
  39. data/test/test_rake_file_utils.rb +6 -2
  40. data/test/test_rake_ftp_file.rb +28 -13
  41. data/test/test_rake_functional.rb +4 -2
  42. data/test/test_rake_makefile_loader.rb +3 -1
  43. data/test/test_rake_multi_task.rb +2 -3
  44. data/test/test_rake_name_space.rb +1 -1
  45. data/test/test_rake_path_map.rb +23 -12
  46. data/test/test_rake_rake_test_loader.rb +2 -3
  47. data/test/test_rake_rules.rb +11 -12
  48. data/test/test_rake_task.rb +7 -7
  49. data/test/test_rake_task_arguments.rb +35 -2
  50. data/test/test_rake_task_manager.rb +3 -4
  51. data/test/test_rake_task_with_arguments.rb +2 -2
  52. data/test/test_rake_test_task.rb +1 -2
  53. data/test/test_rake_thread_pool.rb +36 -16
  54. data/test/test_thread_history_display.rb +16 -6
  55. data/test/test_trace_output.rb +2 -0
  56. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf7d33e05203253446a5a4015f7b1085e268eaaf
4
- data.tar.gz: 488ec5fee795191c32c674c6838232ee8d824e56
3
+ metadata.gz: 6f3ce12012d73dcdfd6cfec09c9c7d22d8d84600
4
+ data.tar.gz: deb2ee15747c685e35e5b29e244ee7a2a9ca55e6
5
5
  SHA512:
6
- metadata.gz: 8498a095b32e5713ad22930c03d577e1601a2be95c2aa23333c4768ebb27059eecdeaa5c986b8218b32ee80f71401559c77b96e676053ea6a32b9b040bf2f0d3
7
- data.tar.gz: 420607f28d7de1fc5cecf40da9d0daff39701a333277d3db884bc2537b3cce60582957921cd26d0485b6b6f79974475b340a4f1bd8b2a93ca0d48ea5dcceaa16
6
+ metadata.gz: 7e1fdf44fc33efa1018d1b936044c6eca8144ae03c7a9a2354f1a1731268ff0f9589c4bf3bd70f2fff41e5813aba982c0ab157514dab3ab0f913550f5ba12d52
7
+ data.tar.gz: 0a102b012351cf09af99924d9e78e48c3f07c091a39ab063304fc4c83a1dcb8490ebfed724efe77f86d7873ec90244cc1beb685534aa4d4c1e678c06fed3758f
@@ -264,6 +264,25 @@ for tasks with arguments. For example:
264
264
  puts "Last name is #{args.last_name}"
265
265
  end
266
266
 
267
+ === Tasks that take Variable-length Parameters
268
+
269
+ Tasks that need to handle a list of values as a parameter can use the
270
+ extras method of the args variable. This allows for tasks that can
271
+ loop over a variable number of values, and its compatible with named
272
+ parameters as well:
273
+
274
+ task :email, [:message] do |t, args|
275
+ mail = Mail.new(args.message)
276
+ recipients = args.extras
277
+ recipients.each do |target|
278
+ mail.send_to(recipents)
279
+ end
280
+ end
281
+
282
+ There is also the convenience method to_a that returns all parameters
283
+ in the sequential order they were given, including those associated
284
+ with named parameters.
285
+
267
286
  === Deprecated Task Parameters Format
268
287
 
269
288
  There is an older format for declaring task parameters that omitted
@@ -39,7 +39,7 @@ module Rake::AltSystem
39
39
  end
40
40
  end
41
41
 
42
- if WINDOWS and RUBY_VERSION < "1.9.0"
42
+ if WINDOWS && RUBY_VERSION < "1.9.0"
43
43
  RUNNABLE_EXTS = %w[com exe bat cmd]
44
44
  RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i
45
45
 
@@ -73,9 +73,8 @@ module Rake::AltSystem
73
73
  file
74
74
  else
75
75
  RUNNABLE_EXTS.each { |ext|
76
- if File.exist?(test = "#{file}.#{ext}")
77
- return test
78
- end
76
+ test = "#{file}.#{ext}"
77
+ return test if File.exist?(test)
79
78
  }
80
79
  nil
81
80
  end
@@ -35,7 +35,12 @@ module Rake
35
35
  # List of the top level task names (task names from the command line).
36
36
  attr_reader :top_level_tasks
37
37
 
38
- DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
38
+ DEFAULT_RAKEFILES = [
39
+ 'rakefile',
40
+ 'Rakefile',
41
+ 'rakefile.rb',
42
+ 'Rakefile.rb'
43
+ ].freeze
39
44
 
40
45
  # Initialize a Rake::Application object.
41
46
  def initialize
@@ -115,7 +120,8 @@ module Rake
115
120
  puts "Maximum active threads: #{stats[:max_active_threads]}"
116
121
  puts "Total threads in play: #{stats[:total_threads_in_play]}"
117
122
  end
118
- ThreadHistoryDisplay.new(thread_pool.history).show if options.job_stats == :history
123
+ ThreadHistoryDisplay.new(thread_pool.history).show if
124
+ options.job_stats == :history
119
125
  end
120
126
 
121
127
  # Add a loader to handle imported files ending in the extension
@@ -132,7 +138,7 @@ module Rake
132
138
 
133
139
  # Return the thread pool used for multithreaded processing.
134
140
  def thread_pool # :nodoc:
135
- @thread_pool ||= ThreadPool.new(options.thread_pool_size||FIXNUM_MAX)
141
+ @thread_pool ||= ThreadPool.new(options.thread_pool_size || FIXNUM_MAX)
136
142
  end
137
143
 
138
144
  # private ----------------------------------------------------------------
@@ -156,19 +162,17 @@ module Rake
156
162
 
157
163
  # Provide standard exception handling for the given block.
158
164
  def standard_exception_handling
159
- begin
160
- yield
161
- rescue SystemExit => ex
162
- # Exit silently with current status
163
- raise
164
- rescue OptionParser::InvalidOption => ex
165
- $stderr.puts ex.message
166
- exit(false)
167
- rescue Exception => ex
168
- # Exit with error message
169
- display_error_message(ex)
170
- exit_because_of_exception(ex)
171
- end
165
+ yield
166
+ rescue SystemExit
167
+ # Exit silently with current status
168
+ raise
169
+ rescue OptionParser::InvalidOption => ex
170
+ $stderr.puts ex.message
171
+ exit(false)
172
+ rescue Exception => ex
173
+ # Exit with error message
174
+ display_error_message(ex)
175
+ exit_because_of_exception(ex)
172
176
  end
173
177
 
174
178
  # Exit the program because of an unhandle exception.
@@ -187,7 +191,8 @@ module Rake
187
191
  trace Backtrace.collapse(ex.backtrace).join("\n")
188
192
  end
189
193
  trace "Tasks: #{ex.chain}" if has_chain?(ex)
190
- trace "(See full trace by running task with --trace)" unless options.backtrace
194
+ trace "(See full trace by running task with --trace)" unless
195
+ options.backtrace
191
196
  end
192
197
 
193
198
  # Warn about deprecated usage.
@@ -229,7 +234,7 @@ module Rake
229
234
  end
230
235
 
231
236
  # Override the detected TTY output state (mostly for testing)
232
- def tty_output=( tty_output_state )
237
+ def tty_output=(tty_output_state)
233
238
  @tty_output = tty_output_state
234
239
  end
235
240
 
@@ -242,16 +247,22 @@ module Rake
242
247
  # Display the tasks and comments.
243
248
  def display_tasks_and_comments
244
249
  displayable_tasks = tasks.select { |t|
245
- (options.show_all_tasks || t.comment) && t.name =~ options.show_task_pattern
250
+ (options.show_all_tasks || t.comment) &&
251
+ t.name =~ options.show_task_pattern
246
252
  }
247
253
  case options.show_tasks
248
254
  when :tasks
249
- width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
250
- max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
255
+ width = displayable_tasks.map { |t| t.name_with_args.length }.max || 10
256
+ if truncate_output?
257
+ max_column = terminal_width - name.size - width - 7
258
+ else
259
+ max_column = nil
260
+ end
251
261
 
252
262
  displayable_tasks.each do |t|
253
- printf "#{name} %-#{width}s # %s\n",
254
- t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
263
+ printf("#{name} %-#{width}s # %s\n",
264
+ t.name_with_args,
265
+ max_column ? truncate(t.comment, max_column) : t.comment)
255
266
  end
256
267
  when :describe
257
268
  displayable_tasks.each do |t|
@@ -265,7 +276,7 @@ module Rake
265
276
  when :lines
266
277
  displayable_tasks.each do |t|
267
278
  t.locations.each do |loc|
268
- printf "#{name} %-30s %s\n",t.name_with_args, loc
279
+ printf "#{name} %-30s %s\n", t.name_with_args, loc
269
280
  end
270
281
  end
271
282
  else
@@ -298,7 +309,8 @@ module Rake
298
309
  end
299
310
 
300
311
  def unix?
301
- RbConfig::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
312
+ RbConfig::CONFIG['host_os'] =~
313
+ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
302
314
  end
303
315
 
304
316
  def windows?
@@ -311,7 +323,7 @@ module Rake
311
323
  elsif string.length <= width
312
324
  string
313
325
  else
314
- ( string[0, width-3] || "" ) + "..."
326
+ (string[0, width - 3] || "") + "..."
315
327
  end
316
328
  end
317
329
 
@@ -340,28 +352,33 @@ module Rake
340
352
  def standard_rake_options
341
353
  sort_options(
342
354
  [
343
- ['--all', '-A', "Show all tasks, even uncommented ones",
355
+ ['--all', '-A',
356
+ "Show all tasks, even uncommented ones",
344
357
  lambda { |value|
345
358
  options.show_all_tasks = value
346
359
  }
347
360
  ],
348
- ['--backtrace=[OUT]', "Enable full backtrace. OUT can be stderr (default) or stdout.",
361
+ ['--backtrace=[OUT]',
362
+ "Enable full backtrace. OUT can be stderr (default) or stdout.",
349
363
  lambda { |value|
350
364
  options.backtrace = true
351
365
  select_trace_output(options, 'backtrace', value)
352
366
  }
353
367
  ],
354
- ['--comments', "Show commented tasks only",
368
+ ['--comments',
369
+ "Show commented tasks only",
355
370
  lambda { |value|
356
371
  options.show_all_tasks = !value
357
372
  }
358
373
  ],
359
- ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
374
+ ['--describe', '-D [PATTERN]',
375
+ "Describe the tasks (matching optional PATTERN), then exit.",
360
376
  lambda { |value|
361
377
  select_tasks_to_show(options, :describe, value)
362
378
  }
363
379
  ],
364
- ['--dry-run', '-n', "Do a dry run without executing actions.",
380
+ ['--dry-run', '-n',
381
+ "Do a dry run without executing actions.",
365
382
  lambda { |value|
366
383
  Rake.verbose(true)
367
384
  Rake.nowrite(true)
@@ -369,28 +386,35 @@ module Rake
369
386
  options.trace = true
370
387
  }
371
388
  ],
372
- ['--execute', '-e CODE', "Execute some Ruby code and exit.",
389
+ ['--execute', '-e CODE',
390
+ "Execute some Ruby code and exit.",
373
391
  lambda { |value|
374
392
  eval(value)
375
393
  exit
376
394
  }
377
395
  ],
378
- ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
396
+ ['--execute-print', '-p CODE',
397
+ "Execute some Ruby code, print the result, then exit.",
379
398
  lambda { |value|
380
399
  puts eval(value)
381
400
  exit
382
401
  }
383
402
  ],
384
403
  ['--execute-continue', '-E CODE',
385
- "Execute some Ruby code, then continue with normal task processing.",
404
+ "Execute some Ruby code, " +
405
+ "then continue with normal task processing.",
386
406
  lambda { |value| eval(value) }
387
407
  ],
388
408
  ['--jobs', '-j [NUMBER]',
389
- "Specifies the maximum number of tasks to execute in parallel. (default:2)",
390
- lambda { |value| options.thread_pool_size = [(value || 2).to_i,2].max }
409
+ "Specifies the maximum number of tasks to execute in parallel. " +
410
+ "(default is 2)",
411
+ lambda { |value|
412
+ options.thread_pool_size = [(value || 2).to_i, 2].max
413
+ }
391
414
  ],
392
415
  ['--job-stats [LEVEL]',
393
- "Display job statistics. LEVEL=history displays a complete job list",
416
+ "Display job statistics. " +
417
+ "LEVEL=history displays a complete job list",
394
418
  lambda { |value|
395
419
  if value =~ /^history/i
396
420
  options.job_stats = :history
@@ -399,22 +423,28 @@ module Rake
399
423
  end
400
424
  }
401
425
  ],
402
- ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
426
+ ['--libdir', '-I LIBDIR',
427
+ "Include LIBDIR in the search path for required modules.",
403
428
  lambda { |value| $:.push(value) }
404
429
  ],
405
- ['--multitask', '-m', "Treat all tasks as multitasks.",
430
+ ['--multitask', '-m',
431
+ "Treat all tasks as multitasks.",
406
432
  lambda { |value| options.always_multitask = true }
407
433
  ],
408
- ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
434
+ ['--no-search', '--nosearch',
435
+ '-N', "Do not search parent directories for the Rakefile.",
409
436
  lambda { |value| options.nosearch = true }
410
437
  ],
411
- ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
438
+ ['--prereqs', '-P',
439
+ "Display the tasks and dependencies, then exit.",
412
440
  lambda { |value| options.show_prereqs = true }
413
441
  ],
414
- ['--quiet', '-q', "Do not log messages to standard output.",
442
+ ['--quiet', '-q',
443
+ "Do not log messages to standard output.",
415
444
  lambda { |value| Rake.verbose(false) }
416
445
  ],
417
- ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
446
+ ['--rakefile', '-f [FILE]',
447
+ "Use FILE as the rakefile.",
418
448
  lambda { |value|
419
449
  value ||= ''
420
450
  @rakefiles.clear
@@ -422,10 +452,14 @@ module Rake
422
452
  }
423
453
  ],
424
454
  ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
425
- "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
426
- lambda { |value| options.rakelib = value.split(File::PATH_SEPARATOR) }
455
+ "Auto-import any .rake files in RAKELIBDIR. " +
456
+ "(default is 'rakelib')",
457
+ lambda { |value|
458
+ options.rakelib = value.split(File::PATH_SEPARATOR)
459
+ }
427
460
  ],
428
- ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
461
+ ['--require', '-r MODULE',
462
+ "Require MODULE before executing rakefile.",
429
463
  lambda { |value|
430
464
  begin
431
465
  require value
@@ -438,34 +472,45 @@ module Rake
438
472
  end
439
473
  }
440
474
  ],
441
- ['--rules', "Trace the rules resolution.",
475
+ ['--rules',
476
+ "Trace the rules resolution.",
442
477
  lambda { |value| options.trace_rules = true }
443
478
  ],
444
- ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
479
+ ['--silent', '-s',
480
+ "Like --quiet, but also suppresses the " +
481
+ "'in directory' announcement.",
445
482
  lambda { |value|
446
483
  Rake.verbose(false)
447
484
  options.silent = true
448
485
  }
449
486
  ],
450
- ['--suppress-backtrace PATTERN', "Suppress backtrace lines matching regexp PATTERN. Ignored if --trace is on.",
487
+ ['--suppress-backtrace PATTERN',
488
+ "Suppress backtrace lines matching regexp PATTERN. " +
489
+ "Ignored if --trace is on.",
451
490
  lambda { |value|
452
491
  options.suppress_backtrace_pattern = Regexp.new(value)
453
492
  }
454
493
  ],
455
494
  ['--system', '-g',
456
- "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
495
+ "Using system wide (global) rakefiles " +
496
+ "(usually '~/.rake/*.rake').",
457
497
  lambda { |value| options.load_system = true }
458
498
  ],
459
499
  ['--no-system', '--nosystem', '-G',
460
- "Use standard project Rakefile search paths, ignore system wide rakefiles.",
500
+ "Use standard project Rakefile search paths, " +
501
+ "ignore system wide rakefiles.",
461
502
  lambda { |value| options.ignore_system = true }
462
503
  ],
463
- ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
504
+ ['--tasks', '-T [PATTERN]',
505
+ "Display the tasks (matching optional PATTERN) " +
506
+ "with descriptions, then exit.",
464
507
  lambda { |value|
465
508
  select_tasks_to_show(options, :tasks, value)
466
509
  }
467
510
  ],
468
- ['--trace=[OUT]', '-t', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
511
+ ['--trace=[OUT]', '-t',
512
+ "Turn on invoke/execute tracing, enable full backtrace. " +
513
+ "OUT can be stderr (default) or stdout.",
469
514
  lambda { |value|
470
515
  options.trace = true
471
516
  options.backtrace = true
@@ -473,22 +518,26 @@ module Rake
473
518
  Rake.verbose(true)
474
519
  }
475
520
  ],
476
- ['--verbose', '-v', "Log message to standard output.",
521
+ ['--verbose', '-v',
522
+ "Log message to standard output.",
477
523
  lambda { |value| Rake.verbose(true) }
478
524
  ],
479
- ['--version', '-V', "Display the program version.",
525
+ ['--version', '-V',
526
+ "Display the program version.",
480
527
  lambda { |value|
481
528
  puts "rake, version #{RAKEVERSION}"
482
529
  exit
483
530
  }
484
531
  ],
485
- ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
532
+ ['--where', '-W [PATTERN]',
533
+ "Describe the tasks (matching optional PATTERN), then exit.",
486
534
  lambda { |value|
487
535
  select_tasks_to_show(options, :lines, value)
488
536
  options.show_all_tasks = true
489
537
  }
490
538
  ],
491
- ['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
539
+ ['--no-deprecation-warnings', '-X',
540
+ "Disable the deprecation warnings.",
492
541
  lambda { |value|
493
542
  options.ignore_deprecate = true
494
543
  }
@@ -511,7 +560,8 @@ module Rake
511
560
  when 'stderr', nil
512
561
  options.trace_output = $stderr
513
562
  else
514
- fail CommandLineOptionError, "Unrecognized --#{trace_option} option '#{value}'"
563
+ fail CommandLineOptionError,
564
+ "Unrecognized --#{trace_option} option '#{value}'"
515
565
  end
516
566
  end
517
567
  private :select_trace_output
@@ -554,11 +604,9 @@ module Rake
554
604
 
555
605
  def find_rakefile_location
556
606
  here = Dir.pwd
557
- while ! (fn = have_rakefile)
607
+ until (fn = have_rakefile)
558
608
  Dir.chdir("..")
559
- if Dir.pwd == here || options.nosearch
560
- return nil
561
- end
609
+ return nil if Dir.pwd == here || options.nosearch
562
610
  here = Dir.pwd
563
611
  end
564
612
  [fn, here]
@@ -586,7 +634,8 @@ module Rake
586
634
  @rakefile = rakefile
587
635
  Dir.chdir(location)
588
636
  print_rakefile_directory(location)
589
- Rake.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != ''
637
+ Rake.load_rakefile(File.expand_path(@rakefile)) if
638
+ @rakefile && @rakefile != ''
590
639
  options.rakelib.each do |rlib|
591
640
  glob("#{rlib}/*.rake") do |name|
592
641
  add_import name
@@ -655,9 +704,7 @@ module Rake
655
704
  def load_imports
656
705
  while fn = @pending_imports.shift
657
706
  next if @imported.member?(fn)
658
- if fn_task = lookup(fn)
659
- fn_task.invoke
660
- end
707
+ fn_task = lookup(fn) and fn_task.invoke
661
708
  ext = File.extname(fn)
662
709
  loader = @loaders[ext] || @default_loader
663
710
  loader.load(fn)
@@ -666,7 +713,7 @@ module Rake
666
713
  end
667
714
 
668
715
  def rakefile_location(backtrace=caller)
669
- backtrace.map { |t| t[/([^:]+):/,1] }
716
+ backtrace.map { |t| t[/([^:]+):/, 1] }
670
717
 
671
718
  re = /^#{@rakefile}$/
672
719
  re = /#{re.source}/i if windows?