rake 10.5.0 → 13.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +2032 -288
  3. data/README.rdoc +40 -24
  4. data/doc/jamis.rb +1 -0
  5. data/doc/rake.1 +139 -124
  6. data/doc/rakefile.rdoc +2 -4
  7. data/{bin → exe}/rake +1 -7
  8. data/lib/rake/application.rb +164 -93
  9. data/lib/rake/backtrace.rb +4 -2
  10. data/lib/rake/clean.rb +7 -5
  11. data/lib/rake/cloneable.rb +1 -0
  12. data/lib/rake/cpu_counter.rb +10 -28
  13. data/lib/rake/default_loader.rb +1 -0
  14. data/lib/rake/dsl_definition.rb +8 -13
  15. data/lib/rake/early_time.rb +1 -0
  16. data/lib/rake/ext/core.rb +1 -0
  17. data/lib/rake/ext/string.rb +22 -21
  18. data/lib/rake/file_creation_task.rb +4 -3
  19. data/lib/rake/file_list.rb +34 -27
  20. data/lib/rake/file_task.rb +19 -7
  21. data/lib/rake/file_utils.rb +37 -33
  22. data/lib/rake/file_utils_ext.rb +8 -18
  23. data/lib/rake/invocation_chain.rb +1 -0
  24. data/lib/rake/invocation_exception_mixin.rb +1 -0
  25. data/lib/rake/late_time.rb +2 -1
  26. data/lib/rake/linked_list.rb +24 -15
  27. data/lib/rake/loaders/makefile.rb +5 -4
  28. data/lib/rake/multi_task.rb +2 -1
  29. data/lib/rake/name_space.rb +1 -1
  30. data/lib/rake/packagetask.rb +40 -17
  31. data/lib/rake/phony.rb +2 -1
  32. data/lib/rake/private_reader.rb +1 -0
  33. data/lib/rake/promise.rb +13 -12
  34. data/lib/rake/pseudo_status.rb +1 -0
  35. data/lib/rake/rake_module.rb +30 -1
  36. data/lib/rake/rake_test_loader.rb +9 -4
  37. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  38. data/lib/rake/scope.rb +3 -2
  39. data/lib/rake/task.rb +82 -31
  40. data/lib/rake/task_argument_error.rb +1 -0
  41. data/lib/rake/task_arguments.rb +15 -4
  42. data/lib/rake/task_manager.rb +56 -32
  43. data/lib/rake/tasklib.rb +2 -14
  44. data/lib/rake/testtask.rb +37 -61
  45. data/lib/rake/thread_history_display.rb +4 -3
  46. data/lib/rake/thread_pool.rb +16 -17
  47. data/lib/rake/trace_output.rb +2 -1
  48. data/lib/rake/version.rb +4 -1
  49. data/lib/rake/win32.rb +10 -15
  50. data/lib/rake.rb +34 -43
  51. data/rake.gemspec +101 -0
  52. metadata +24 -223
  53. data/.autotest +0 -7
  54. data/.rubocop.yml +0 -27
  55. data/.togglerc +0 -7
  56. data/CONTRIBUTING.rdoc +0 -38
  57. data/Manifest.txt +0 -166
  58. data/Rakefile +0 -81
  59. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  60. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  61. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  62. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  63. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  64. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  65. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  66. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  67. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  68. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  69. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  70. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  71. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  72. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  73. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  74. data/doc/release_notes/rake-0.8.6.rdoc +0 -37
  75. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  76. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  77. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  78. data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
  79. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  80. data/doc/release_notes/rake-0.9.3.rdoc +0 -102
  81. data/doc/release_notes/rake-0.9.4.rdoc +0 -60
  82. data/doc/release_notes/rake-0.9.5.rdoc +0 -55
  83. data/doc/release_notes/rake-0.9.6.rdoc +0 -64
  84. data/doc/release_notes/rake-10.0.0.rdoc +0 -178
  85. data/doc/release_notes/rake-10.0.1.rdoc +0 -58
  86. data/doc/release_notes/rake-10.0.2.rdoc +0 -53
  87. data/doc/release_notes/rake-10.0.3.rdoc +0 -191
  88. data/doc/release_notes/rake-10.1.0.rdoc +0 -61
  89. data/lib/rake/alt_system.rb +0 -110
  90. data/lib/rake/contrib/.document +0 -1
  91. data/lib/rake/contrib/compositepublisher.rb +0 -21
  92. data/lib/rake/contrib/ftptools.rb +0 -137
  93. data/lib/rake/contrib/publisher.rb +0 -81
  94. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  95. data/lib/rake/contrib/sshpublisher.rb +0 -61
  96. data/lib/rake/contrib/sys.rb +0 -4
  97. data/lib/rake/ext/module.rb +0 -2
  98. data/lib/rake/ext/pathname.rb +0 -25
  99. data/lib/rake/ext/time.rb +0 -18
  100. data/lib/rake/gempackagetask.rb +0 -4
  101. data/lib/rake/pathmap.rb +0 -3
  102. data/lib/rake/rdoctask.rb +0 -4
  103. data/lib/rake/ruby182_test_unit_fix.rb +0 -29
  104. data/lib/rake/runtest.rb +0 -27
  105. data/rakelib/publish.rake +0 -20
  106. data/rakelib/test_times.rake +0 -25
  107. data/test/file_creation.rb +0 -34
  108. data/test/helper.rb +0 -129
  109. data/test/support/rakefile_definitions.rb +0 -478
  110. data/test/support/ruby_runner.rb +0 -34
  111. data/test/test_private_reader.rb +0 -42
  112. data/test/test_rake.rb +0 -40
  113. data/test/test_rake_application.rb +0 -643
  114. data/test/test_rake_application_options.rb +0 -468
  115. data/test/test_rake_backtrace.rb +0 -119
  116. data/test/test_rake_clean.rb +0 -61
  117. data/test/test_rake_cpu_counter.rb +0 -68
  118. data/test/test_rake_definitions.rb +0 -84
  119. data/test/test_rake_directory_task.rb +0 -76
  120. data/test/test_rake_dsl.rb +0 -40
  121. data/test/test_rake_early_time.rb +0 -31
  122. data/test/test_rake_extension.rb +0 -59
  123. data/test/test_rake_file_creation_task.rb +0 -56
  124. data/test/test_rake_file_list.rb +0 -670
  125. data/test/test_rake_file_list_path_map.rb +0 -8
  126. data/test/test_rake_file_task.rb +0 -197
  127. data/test/test_rake_file_utils.rb +0 -314
  128. data/test/test_rake_ftp_file.rb +0 -74
  129. data/test/test_rake_functional.rb +0 -482
  130. data/test/test_rake_invocation_chain.rb +0 -64
  131. data/test/test_rake_late_time.rb +0 -18
  132. data/test/test_rake_linked_list.rb +0 -84
  133. data/test/test_rake_makefile_loader.rb +0 -46
  134. data/test/test_rake_multi_task.rb +0 -64
  135. data/test/test_rake_name_space.rb +0 -57
  136. data/test/test_rake_package_task.rb +0 -79
  137. data/test/test_rake_path_map.rb +0 -168
  138. data/test/test_rake_path_map_explode.rb +0 -34
  139. data/test/test_rake_path_map_partial.rb +0 -18
  140. data/test/test_rake_pathname_extensions.rb +0 -15
  141. data/test/test_rake_pseudo_status.rb +0 -21
  142. data/test/test_rake_rake_test_loader.rb +0 -20
  143. data/test/test_rake_reduce_compat.rb +0 -26
  144. data/test/test_rake_require.rb +0 -40
  145. data/test/test_rake_rules.rb +0 -388
  146. data/test/test_rake_scope.rb +0 -44
  147. data/test/test_rake_task.rb +0 -393
  148. data/test/test_rake_task_argument_parsing.rb +0 -119
  149. data/test/test_rake_task_arguments.rb +0 -127
  150. data/test/test_rake_task_lib.rb +0 -9
  151. data/test/test_rake_task_manager.rb +0 -178
  152. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  153. data/test/test_rake_task_with_arguments.rb +0 -172
  154. data/test/test_rake_test_task.rb +0 -146
  155. data/test/test_rake_thread_pool.rb +0 -145
  156. data/test/test_rake_top_level_functions.rb +0 -71
  157. data/test/test_rake_win32.rb +0 -72
  158. data/test/test_thread_history_display.rb +0 -101
  159. data/test/test_trace_output.rb +0 -52
@@ -1,12 +1,12 @@
1
- require 'shellwords'
2
- require 'optparse'
1
+ # frozen_string_literal: true
2
+ require "optparse"
3
3
 
4
- require 'rake/task_manager'
5
- require 'rake/file_list'
6
- require 'rake/thread_pool'
7
- require 'rake/thread_history_display'
8
- require 'rake/trace_output'
9
- require 'rake/win32'
4
+ require "rake/task_manager"
5
+ require "rake/file_list"
6
+ require "rake/thread_pool"
7
+ require "rake/thread_history_display"
8
+ require "rake/trace_output"
9
+ require "rake/win32"
10
10
 
11
11
  module Rake
12
12
 
@@ -35,17 +35,20 @@ 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
+ # Override the detected TTY output state (mostly for testing)
39
+ attr_writer :tty_output
40
+
38
41
  DEFAULT_RAKEFILES = [
39
- 'rakefile',
40
- 'Rakefile',
41
- 'rakefile.rb',
42
- 'Rakefile.rb'
42
+ "rakefile",
43
+ "Rakefile",
44
+ "rakefile.rb",
45
+ "Rakefile.rb"
43
46
  ].freeze
44
47
 
45
48
  # Initialize a Rake::Application object.
46
49
  def initialize
47
50
  super
48
- @name = 'rake'
51
+ @name = "rake"
49
52
  @rakefiles = DEFAULT_RAKEFILES.dup
50
53
  @rakefile = nil
51
54
  @pending_imports = []
@@ -54,11 +57,13 @@ module Rake
54
57
  @default_loader = Rake::DefaultLoader.new
55
58
  @original_dir = Dir.pwd
56
59
  @top_level_tasks = []
57
- add_loader('rb', DefaultLoader.new)
58
- add_loader('rf', DefaultLoader.new)
59
- add_loader('rake', DefaultLoader.new)
60
+ add_loader("rb", DefaultLoader.new)
61
+ add_loader("rf", DefaultLoader.new)
62
+ add_loader("rake", DefaultLoader.new)
60
63
  @tty_output = STDOUT.tty?
61
- @terminal_columns = ENV['RAKE_COLUMNS'].to_i
64
+ @terminal_columns = ENV["RAKE_COLUMNS"].to_i
65
+
66
+ set_default_options
62
67
  end
63
68
 
64
69
  # Run the Rake application. The run method performs the following
@@ -71,23 +76,50 @@ module Rake
71
76
  # If you wish to build a custom rake command, you should call
72
77
  # +init+ on your application. Then define any tasks. Finally,
73
78
  # call +top_level+ to run your top level tasks.
74
- def run
79
+ def run(argv = ARGV)
75
80
  standard_exception_handling do
76
- init
81
+ init "rake", argv
77
82
  load_rakefile
78
83
  top_level
79
84
  end
80
85
  end
81
86
 
82
87
  # Initialize the command line parameters and app name.
83
- def init(app_name='rake')
88
+ def init(app_name="rake", argv = ARGV)
84
89
  standard_exception_handling do
85
90
  @name = app_name
86
- args = handle_options
91
+ begin
92
+ args = handle_options argv
93
+ rescue ArgumentError
94
+ # Backward compatibility for capistrano
95
+ args = handle_options
96
+ end
97
+ load_debug_at_stop_feature
87
98
  collect_command_line_tasks(args)
88
99
  end
89
100
  end
90
101
 
102
+ def load_debug_at_stop_feature
103
+ return unless ENV["RAKE_DEBUG"]
104
+ require "debug/session"
105
+ DEBUGGER__::start no_sigint_hook: true, nonstop: true
106
+ Rake::Task.prepend Module.new {
107
+ def execute(*)
108
+ exception = DEBUGGER__::SESSION.capture_exception_frames(/(exe|bin|lib)\/rake/) do
109
+ super
110
+ end
111
+
112
+ if exception
113
+ STDERR.puts exception.message
114
+ DEBUGGER__::SESSION.enter_postmortem_session exception
115
+ raise exception
116
+ end
117
+ end
118
+ }
119
+ rescue LoadError
120
+ end
121
+ private :load_debug_at_stop_feature
122
+
91
123
  # Find the rakefile and then load it and any pending imports.
92
124
  def load_rakefile
93
125
  standard_exception_handling do
@@ -114,7 +146,7 @@ module Rake
114
146
 
115
147
  yield
116
148
 
117
- thread_pool.join
149
+ thread_pool.join if defined?(@thread_pool)
118
150
  if options.job_stats
119
151
  stats = thread_pool.statistics
120
152
  puts "Maximum active threads: #{stats[:max_active_threads]} + main"
@@ -133,7 +165,13 @@ module Rake
133
165
 
134
166
  # Application options from the command line
135
167
  def options
136
- @options ||= OpenStruct.new
168
+ @options ||= Struct.new(
169
+ :always_multitask, :backtrace, :build_all, :dryrun,
170
+ :ignore_deprecate, :ignore_system, :job_stats, :load_system,
171
+ :nosearch, :rakelib, :show_all_tasks, :show_prereqs,
172
+ :show_task_pattern, :show_tasks, :silent, :suppress_backtrace_pattern,
173
+ :thread_pool_size, :trace, :trace_output, :trace_rules
174
+ ).new
137
175
  end
138
176
 
139
177
  # Return the thread pool used for multithreaded processing.
@@ -162,7 +200,7 @@ module Rake
162
200
  args = []
163
201
 
164
202
  begin
165
- /((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
203
+ /\s*((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
166
204
 
167
205
  remaining_args = $2
168
206
  args << $1.gsub(/\\(.)/, '\1')
@@ -202,13 +240,22 @@ module Rake
202
240
  end
203
241
 
204
242
  def display_exception_details(ex) # :nodoc:
205
- seen = Thread.current[:rake_display_exception_details_seen] ||= []
206
- return if seen.include? ex
207
- seen << ex
243
+ display_exception_details_seen << ex
208
244
 
209
245
  display_exception_message_details(ex)
210
- display_exception_backtrace(ex)
211
- display_exception_details(ex.cause) if has_cause?(ex)
246
+ display_exception_backtrace(ex) if ex.backtrace
247
+ display_cause_details(ex.cause) if has_cause?(ex)
248
+ end
249
+
250
+ def display_cause_details(ex) # :nodoc:
251
+ return if display_exception_details_seen.include? ex
252
+
253
+ trace "\nCaused by:"
254
+ display_exception_details(ex)
255
+ end
256
+
257
+ def display_exception_details_seen # :nodoc:
258
+ Thread.current[:rake_display_exception_details_seen] ||= []
212
259
  end
213
260
 
214
261
  def has_cause?(ex) # :nodoc:
@@ -218,6 +265,8 @@ module Rake
218
265
  def display_exception_message_details(ex) # :nodoc:
219
266
  if ex.instance_of?(RuntimeError)
220
267
  trace ex.message
268
+ elsif ex.respond_to?(:detailed_message)
269
+ trace "#{ex.class.name}: #{ex.detailed_message(highlight: false)}"
221
270
  else
222
271
  trace "#{ex.class.name}: #{ex.message}"
223
272
  end
@@ -257,7 +306,7 @@ module Rake
257
306
  if File.exist?(fn)
258
307
  others = FileList.glob(fn, File::FNM_CASEFOLD)
259
308
  return others.size == 1 ? others.first : fn
260
- elsif fn == ''
309
+ elsif fn == ""
261
310
  return fn
262
311
  end
263
312
  end
@@ -269,11 +318,6 @@ module Rake
269
318
  @tty_output
270
319
  end
271
320
 
272
- # Override the detected TTY output state (mostly for testing)
273
- def tty_output=(tty_output_state) # :nodoc:
274
- @tty_output = tty_output_state
275
- end
276
-
277
321
  # We will truncate output if we are outputting to a TTY or if we've been
278
322
  # given an explicit column width to honor
279
323
  def truncate_output? # :nodoc:
@@ -345,7 +389,7 @@ module Rake
345
389
  end
346
390
 
347
391
  def unix? # :nodoc:
348
- RbConfig::CONFIG['host_os'] =~
392
+ RbConfig::CONFIG["host_os"] =~
349
393
  /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
350
394
  end
351
395
 
@@ -378,7 +422,7 @@ module Rake
378
422
 
379
423
  def sort_options(options) # :nodoc:
380
424
  options.sort_by { |opt|
381
- opt.select { |o| o =~ /^-/ }.map { |o| o.downcase }.sort.reverse
425
+ opt.select { |o| o.is_a?(String) && o =~ /^-/ }.map(&:downcase).sort.reverse
382
426
  }
383
427
  end
384
428
  private :sort_options
@@ -388,38 +432,45 @@ module Rake
388
432
  def standard_rake_options # :nodoc:
389
433
  sort_options(
390
434
  [
391
- ['--all', '-A',
435
+ ["--all", "-A",
392
436
  "Show all tasks, even uncommented ones (in combination with -T or -D)",
393
437
  lambda { |value|
394
438
  options.show_all_tasks = value
395
439
  }
396
440
  ],
397
- ['--backtrace=[OUT]',
441
+ ["--backtrace=[OUT]",
398
442
  "Enable full backtrace. OUT can be stderr (default) or stdout.",
399
443
  lambda { |value|
400
444
  options.backtrace = true
401
- select_trace_output(options, 'backtrace', value)
445
+ select_trace_output(options, "backtrace", value)
402
446
  }
403
447
  ],
404
- ['--build-all', '-B',
448
+ ["--build-all", "-B",
405
449
  "Build all prerequisites, including those which are up-to-date.",
406
450
  lambda { |value|
407
451
  options.build_all = true
408
452
  }
409
453
  ],
410
- ['--comments',
454
+ ["--comments",
411
455
  "Show commented tasks only",
412
456
  lambda { |value|
413
457
  options.show_all_tasks = !value
414
458
  }
415
459
  ],
416
- ['--describe', '-D [PATTERN]',
460
+ ["--describe", "-D [PATTERN]",
417
461
  "Describe the tasks (matching optional PATTERN), then exit.",
418
462
  lambda { |value|
419
463
  select_tasks_to_show(options, :describe, value)
420
464
  }
421
465
  ],
422
- ['--dry-run', '-n',
466
+ ["--directory", "-C [DIRECTORY]",
467
+ "Change to DIRECTORY before doing anything.",
468
+ lambda { |value|
469
+ Dir.chdir value
470
+ @original_dir = Dir.pwd
471
+ }
472
+ ],
473
+ ["--dry-run", "-n",
423
474
  "Do a dry run without executing actions.",
424
475
  lambda { |value|
425
476
  Rake.verbose(true)
@@ -428,31 +479,31 @@ module Rake
428
479
  options.trace = true
429
480
  }
430
481
  ],
431
- ['--execute', '-e CODE',
482
+ ["--execute", "-e CODE",
432
483
  "Execute some Ruby code and exit.",
433
484
  lambda { |value|
434
485
  eval(value)
435
486
  exit
436
487
  }
437
488
  ],
438
- ['--execute-print', '-p CODE',
489
+ ["--execute-print", "-p CODE",
439
490
  "Execute some Ruby code, print the result, then exit.",
440
491
  lambda { |value|
441
492
  puts eval(value)
442
493
  exit
443
494
  }
444
495
  ],
445
- ['--execute-continue', '-E CODE',
496
+ ["--execute-continue", "-E CODE",
446
497
  "Execute some Ruby code, " +
447
498
  "then continue with normal task processing.",
448
499
  lambda { |value| eval(value) }
449
500
  ],
450
- ['--jobs', '-j [NUMBER]',
501
+ ["--jobs", "-j [NUMBER]",
451
502
  "Specifies the maximum number of tasks to execute in parallel. " +
452
503
  "(default is number of CPU cores + 4)",
453
504
  lambda { |value|
454
- if value.nil? || value == ''
455
- value = FIXNUM_MAX
505
+ if value.nil? || value == ""
506
+ value = Float::INFINITY
456
507
  elsif value =~ /^\d+$/
457
508
  value = value.to_i
458
509
  else
@@ -462,7 +513,7 @@ module Rake
462
513
  options.thread_pool_size = value - 1
463
514
  }
464
515
  ],
465
- ['--job-stats [LEVEL]',
516
+ ["--job-stats [LEVEL]",
466
517
  "Display job statistics. " +
467
518
  "LEVEL=history displays a complete job list",
468
519
  lambda { |value|
@@ -473,42 +524,42 @@ module Rake
473
524
  end
474
525
  }
475
526
  ],
476
- ['--libdir', '-I LIBDIR',
527
+ ["--libdir", "-I LIBDIR",
477
528
  "Include LIBDIR in the search path for required modules.",
478
529
  lambda { |value| $:.push(value) }
479
530
  ],
480
- ['--multitask', '-m',
531
+ ["--multitask", "-m",
481
532
  "Treat all tasks as multitasks.",
482
533
  lambda { |value| options.always_multitask = true }
483
534
  ],
484
- ['--no-search', '--nosearch',
485
- '-N', "Do not search parent directories for the Rakefile.",
535
+ ["--no-search", "--nosearch",
536
+ "-N", "Do not search parent directories for the Rakefile.",
486
537
  lambda { |value| options.nosearch = true }
487
538
  ],
488
- ['--prereqs', '-P',
539
+ ["--prereqs", "-P",
489
540
  "Display the tasks and dependencies, then exit.",
490
541
  lambda { |value| options.show_prereqs = true }
491
542
  ],
492
- ['--quiet', '-q',
543
+ ["--quiet", "-q",
493
544
  "Do not log messages to standard output.",
494
545
  lambda { |value| Rake.verbose(false) }
495
546
  ],
496
- ['--rakefile', '-f [FILENAME]',
547
+ ["--rakefile", "-f [FILENAME]",
497
548
  "Use FILENAME as the rakefile to search for.",
498
549
  lambda { |value|
499
- value ||= ''
550
+ value ||= ""
500
551
  @rakefiles.clear
501
552
  @rakefiles << value
502
553
  }
503
554
  ],
504
- ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
555
+ ["--rakelibdir", "--rakelib", "-R RAKELIBDIR",
505
556
  "Auto-import any .rake files in RAKELIBDIR. " +
506
557
  "(default is 'rakelib')",
507
558
  lambda { |value|
508
559
  options.rakelib = value.split(File::PATH_SEPARATOR)
509
560
  }
510
561
  ],
511
- ['--require', '-r MODULE',
562
+ ["--require", "-r MODULE",
512
563
  "Require MODULE before executing rakefile.",
513
564
  lambda { |value|
514
565
  begin
@@ -522,11 +573,11 @@ module Rake
522
573
  end
523
574
  }
524
575
  ],
525
- ['--rules',
576
+ ["--rules",
526
577
  "Trace the rules resolution.",
527
578
  lambda { |value| options.trace_rules = true }
528
579
  ],
529
- ['--silent', '-s',
580
+ ["--silent", "-s",
530
581
  "Like --quiet, but also suppresses the " +
531
582
  "'in directory' announcement.",
532
583
  lambda { |value|
@@ -534,59 +585,60 @@ module Rake
534
585
  options.silent = true
535
586
  }
536
587
  ],
537
- ['--suppress-backtrace PATTERN',
588
+ ["--suppress-backtrace PATTERN",
538
589
  "Suppress backtrace lines matching regexp PATTERN. " +
539
590
  "Ignored if --trace is on.",
540
591
  lambda { |value|
541
592
  options.suppress_backtrace_pattern = Regexp.new(value)
542
593
  }
543
594
  ],
544
- ['--system', '-g',
595
+ ["--system", "-g",
545
596
  "Using system wide (global) rakefiles " +
546
597
  "(usually '~/.rake/*.rake').",
547
598
  lambda { |value| options.load_system = true }
548
599
  ],
549
- ['--no-system', '--nosystem', '-G',
600
+ ["--no-system", "--nosystem", "-G",
550
601
  "Use standard project Rakefile search paths, " +
551
602
  "ignore system wide rakefiles.",
552
603
  lambda { |value| options.ignore_system = true }
553
604
  ],
554
- ['--tasks', '-T [PATTERN]',
605
+ ["--tasks", "-T [PATTERN]",
555
606
  "Display the tasks (matching optional PATTERN) " +
556
- "with descriptions, then exit.",
607
+ "with descriptions, then exit. " +
608
+ "-AT combination displays all the tasks, including those without descriptions.",
557
609
  lambda { |value|
558
610
  select_tasks_to_show(options, :tasks, value)
559
611
  }
560
612
  ],
561
- ['--trace=[OUT]', '-t',
613
+ ["--trace=[OUT]", "-t",
562
614
  "Turn on invoke/execute tracing, enable full backtrace. " +
563
615
  "OUT can be stderr (default) or stdout.",
564
616
  lambda { |value|
565
617
  options.trace = true
566
618
  options.backtrace = true
567
- select_trace_output(options, 'trace', value)
619
+ select_trace_output(options, "trace", value)
568
620
  Rake.verbose(true)
569
621
  }
570
622
  ],
571
- ['--verbose', '-v',
623
+ ["--verbose", "-v",
572
624
  "Log message to standard output.",
573
625
  lambda { |value| Rake.verbose(true) }
574
626
  ],
575
- ['--version', '-V',
627
+ ["--version", "-V",
576
628
  "Display the program version.",
577
629
  lambda { |value|
578
- puts "rake, version #{RAKEVERSION}"
630
+ puts "rake, version #{Rake::VERSION}"
579
631
  exit
580
632
  }
581
633
  ],
582
- ['--where', '-W [PATTERN]',
634
+ ["--where", "-W [PATTERN]",
583
635
  "Describe the tasks (matching optional PATTERN), then exit.",
584
636
  lambda { |value|
585
637
  select_tasks_to_show(options, :lines, value)
586
638
  options.show_all_tasks = true
587
639
  }
588
640
  ],
589
- ['--no-deprecation-warnings', '-X',
641
+ ["--no-deprecation-warnings", "-X",
590
642
  "Disable the deprecation warnings.",
591
643
  lambda { |value|
592
644
  options.ignore_deprecate = true
@@ -597,7 +649,7 @@ module Rake
597
649
 
598
650
  def select_tasks_to_show(options, show_tasks, value) # :nodoc:
599
651
  options.show_tasks = show_tasks
600
- options.show_task_pattern = Regexp.new(value || '')
652
+ options.show_task_pattern = Regexp.new(value || "")
601
653
  Rake::TaskManager.record_task_metadata = true
602
654
  end
603
655
  private :select_tasks_to_show
@@ -605,9 +657,9 @@ module Rake
605
657
  def select_trace_output(options, trace_option, value) # :nodoc:
606
658
  value = value.strip unless value.nil?
607
659
  case value
608
- when 'stdout'
660
+ when "stdout"
609
661
  options.trace_output = $stdout
610
- when 'stderr', nil
662
+ when "stderr", nil
611
663
  options.trace_output = $stderr
612
664
  else
613
665
  fail CommandLineOptionError,
@@ -619,9 +671,8 @@ module Rake
619
671
  # Read and handle the command line options. Returns the command line
620
672
  # arguments that we didn't understand, which should (in theory) be just
621
673
  # task names and env vars.
622
- def handle_options # :nodoc:
623
- options.rakelib = ['rakelib']
624
- options.trace_output = $stderr
674
+ def handle_options(argv) # :nodoc:
675
+ set_default_options
625
676
 
626
677
  OptionParser.new do |opts|
627
678
  opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..."
@@ -634,8 +685,8 @@ module Rake
634
685
  end
635
686
 
636
687
  standard_rake_options.each { |args| opts.on(*args) }
637
- opts.environment('RAKEOPT')
638
- end.parse(ARGV)
688
+ opts.environment("RAKEOPT")
689
+ end.parse(argv)
639
690
  end
640
691
 
641
692
  # Similar to the regular Ruby +require+ command, but will check
@@ -673,7 +724,7 @@ module Rake
673
724
 
674
725
  def raw_load_rakefile # :nodoc:
675
726
  rakefile, location = find_rakefile_location
676
- if (! options.ignore_system) &&
727
+ if (!options.ignore_system) &&
677
728
  (options.load_system || rakefile.nil?) &&
678
729
  system_dir && File.directory?(system_dir)
679
730
  print_rakefile_directory(location)
@@ -687,7 +738,7 @@ module Rake
687
738
  Dir.chdir(location)
688
739
  print_rakefile_directory(location)
689
740
  Rake.load_rakefile(File.expand_path(@rakefile)) if
690
- @rakefile && @rakefile != ''
741
+ @rakefile && @rakefile != ""
691
742
  options.rakelib.each do |rlib|
692
743
  glob("#{rlib}/*.rake") do |name|
693
744
  add_import name
@@ -698,7 +749,7 @@ module Rake
698
749
  end
699
750
 
700
751
  def glob(path, &block) # :nodoc:
701
- FileList.glob(path.gsub("\\", '/')).each(&block)
752
+ FileList.glob(path.tr("\\", "/")).each(&block)
702
753
  end
703
754
  private :glob
704
755
 
@@ -706,8 +757,8 @@ module Rake
706
757
  def system_dir # :nodoc:
707
758
  @system_dir ||=
708
759
  begin
709
- if ENV['RAKE_SYSTEM']
710
- ENV['RAKE_SYSTEM']
760
+ if ENV["RAKE_SYSTEM"]
761
+ ENV["RAKE_SYSTEM"]
711
762
  else
712
763
  standard_system_dir
713
764
  end
@@ -721,7 +772,7 @@ module Rake
721
772
  end
722
773
  else
723
774
  def standard_system_dir #:nodoc:
724
- File.join(File.expand_path('~'), '.rake')
775
+ File.join(File.expand_path("~"), ".rake")
725
776
  end
726
777
  end
727
778
  private :standard_system_dir
@@ -780,11 +831,31 @@ module Rake
780
831
  re = /^#{@rakefile}$/
781
832
  re = /#{re.source}/i if windows?
782
833
 
783
- backtrace.find { |str| str =~ re } || ''
834
+ backtrace.find { |str| str =~ re } || ""
835
+ end
836
+
837
+ def set_default_options # :nodoc:
838
+ options.always_multitask = false
839
+ options.backtrace = false
840
+ options.build_all = false
841
+ options.dryrun = false
842
+ options.ignore_deprecate = false
843
+ options.ignore_system = false
844
+ options.job_stats = false
845
+ options.load_system = false
846
+ options.nosearch = false
847
+ options.rakelib = %w[rakelib]
848
+ options.show_all_tasks = false
849
+ options.show_prereqs = false
850
+ options.show_task_pattern = nil
851
+ options.show_tasks = nil
852
+ options.silent = false
853
+ options.suppress_backtrace_pattern = nil
854
+ options.thread_pool_size = Rake.suggested_thread_count
855
+ options.trace = false
856
+ options.trace_output = $stderr
857
+ options.trace_rules = false
784
858
  end
785
859
 
786
- private
787
- FIXNUM_MAX = (2**(0.size * 8 - 2) - 1) # :nodoc:
788
-
789
860
  end
790
861
  end
@@ -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,13 @@ 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("|")
13
+ SUPPRESSED_PATHS_RE << "|^<internal:\\w+>"
12
14
  SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if
13
- Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
15
+ Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == "jruby"
14
16
 
15
17
  SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i
16
18
 
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."
@@ -71,6 +73,6 @@ end
71
73
  CLOBBER = ::Rake::FileList.new
72
74
 
73
75
  desc "Remove any generated files."
74
- task :clobber => [:clean] do
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.