rake 10.5.0 → 13.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/macos.yml +22 -0
  3. data/.github/workflows/ubuntu-rvm.yml +28 -0
  4. data/.github/workflows/ubuntu.yml +20 -0
  5. data/.github/workflows/windows.yml +20 -0
  6. data/CONTRIBUTING.rdoc +13 -8
  7. data/Gemfile +10 -0
  8. data/History.rdoc +1997 -288
  9. data/README.rdoc +27 -11
  10. data/Rakefile +25 -65
  11. data/bin/bundle +105 -0
  12. data/bin/console +7 -0
  13. data/bin/rake +20 -24
  14. data/bin/rdoc +29 -0
  15. data/bin/rubocop +29 -0
  16. data/bin/setup +6 -0
  17. data/doc/jamis.rb +1 -0
  18. data/doc/rake.1 +139 -124
  19. data/doc/rakefile.rdoc +2 -4
  20. data/exe/rake +27 -0
  21. data/lib/rake/application.rb +124 -90
  22. data/lib/rake/backtrace.rb +3 -2
  23. data/lib/rake/clean.rb +7 -5
  24. data/lib/rake/cloneable.rb +1 -0
  25. data/lib/rake/cpu_counter.rb +10 -28
  26. data/lib/rake/default_loader.rb +1 -0
  27. data/lib/rake/dsl_definition.rb +5 -11
  28. data/lib/rake/early_time.rb +1 -0
  29. data/lib/rake/ext/core.rb +1 -0
  30. data/lib/rake/ext/string.rb +22 -21
  31. data/lib/rake/file_creation_task.rb +4 -3
  32. data/lib/rake/file_list.rb +34 -27
  33. data/lib/rake/file_task.rb +12 -4
  34. data/lib/rake/file_utils.rb +38 -32
  35. data/lib/rake/file_utils_ext.rb +8 -18
  36. data/lib/rake/invocation_chain.rb +1 -0
  37. data/lib/rake/invocation_exception_mixin.rb +1 -0
  38. data/lib/rake/late_time.rb +2 -1
  39. data/lib/rake/linked_list.rb +24 -15
  40. data/lib/rake/loaders/makefile.rb +5 -4
  41. data/lib/rake/multi_task.rb +2 -1
  42. data/lib/rake/name_space.rb +1 -1
  43. data/lib/rake/packagetask.rb +40 -17
  44. data/lib/rake/phony.rb +2 -1
  45. data/lib/rake/private_reader.rb +1 -0
  46. data/lib/rake/promise.rb +13 -12
  47. data/lib/rake/pseudo_status.rb +1 -0
  48. data/lib/rake/rake_module.rb +30 -1
  49. data/lib/rake/rake_test_loader.rb +18 -13
  50. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  51. data/lib/rake/scope.rb +3 -2
  52. data/lib/rake/task.rb +82 -31
  53. data/lib/rake/task_argument_error.rb +1 -0
  54. data/lib/rake/task_arguments.rb +15 -4
  55. data/lib/rake/task_manager.rb +54 -30
  56. data/lib/rake/tasklib.rb +2 -14
  57. data/lib/rake/testtask.rb +39 -28
  58. data/lib/rake/thread_history_display.rb +4 -3
  59. data/lib/rake/thread_pool.rb +16 -17
  60. data/lib/rake/trace_output.rb +2 -1
  61. data/lib/rake/version.rb +4 -1
  62. data/lib/rake/win32.rb +10 -15
  63. data/lib/rake.rb +35 -43
  64. data/rake.gemspec +43 -0
  65. metadata +33 -216
  66. data/.autotest +0 -7
  67. data/.rubocop.yml +0 -27
  68. data/.togglerc +0 -7
  69. data/Manifest.txt +0 -166
  70. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  71. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  72. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  73. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  74. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  75. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  76. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  77. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  78. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  79. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  80. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  81. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  82. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  83. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  84. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  85. data/doc/release_notes/rake-0.8.6.rdoc +0 -37
  86. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  87. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  88. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  89. data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
  90. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  91. data/doc/release_notes/rake-0.9.3.rdoc +0 -102
  92. data/doc/release_notes/rake-0.9.4.rdoc +0 -60
  93. data/doc/release_notes/rake-0.9.5.rdoc +0 -55
  94. data/doc/release_notes/rake-0.9.6.rdoc +0 -64
  95. data/doc/release_notes/rake-10.0.0.rdoc +0 -178
  96. data/doc/release_notes/rake-10.0.1.rdoc +0 -58
  97. data/doc/release_notes/rake-10.0.2.rdoc +0 -53
  98. data/doc/release_notes/rake-10.0.3.rdoc +0 -191
  99. data/doc/release_notes/rake-10.1.0.rdoc +0 -61
  100. data/lib/rake/alt_system.rb +0 -110
  101. data/lib/rake/contrib/.document +0 -1
  102. data/lib/rake/contrib/compositepublisher.rb +0 -21
  103. data/lib/rake/contrib/ftptools.rb +0 -137
  104. data/lib/rake/contrib/publisher.rb +0 -81
  105. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  106. data/lib/rake/contrib/sshpublisher.rb +0 -61
  107. data/lib/rake/contrib/sys.rb +0 -4
  108. data/lib/rake/ext/module.rb +0 -2
  109. data/lib/rake/ext/pathname.rb +0 -25
  110. data/lib/rake/ext/time.rb +0 -18
  111. data/lib/rake/gempackagetask.rb +0 -4
  112. data/lib/rake/pathmap.rb +0 -3
  113. data/lib/rake/rdoctask.rb +0 -4
  114. data/lib/rake/ruby182_test_unit_fix.rb +0 -29
  115. data/lib/rake/runtest.rb +0 -27
  116. data/rakelib/publish.rake +0 -20
  117. data/rakelib/test_times.rake +0 -25
  118. data/test/file_creation.rb +0 -34
  119. data/test/helper.rb +0 -129
  120. data/test/support/rakefile_definitions.rb +0 -478
  121. data/test/support/ruby_runner.rb +0 -34
  122. data/test/test_private_reader.rb +0 -42
  123. data/test/test_rake.rb +0 -40
  124. data/test/test_rake_application.rb +0 -643
  125. data/test/test_rake_application_options.rb +0 -468
  126. data/test/test_rake_backtrace.rb +0 -119
  127. data/test/test_rake_clean.rb +0 -61
  128. data/test/test_rake_cpu_counter.rb +0 -68
  129. data/test/test_rake_definitions.rb +0 -84
  130. data/test/test_rake_directory_task.rb +0 -76
  131. data/test/test_rake_dsl.rb +0 -40
  132. data/test/test_rake_early_time.rb +0 -31
  133. data/test/test_rake_extension.rb +0 -59
  134. data/test/test_rake_file_creation_task.rb +0 -56
  135. data/test/test_rake_file_list.rb +0 -670
  136. data/test/test_rake_file_list_path_map.rb +0 -8
  137. data/test/test_rake_file_task.rb +0 -197
  138. data/test/test_rake_file_utils.rb +0 -314
  139. data/test/test_rake_ftp_file.rb +0 -74
  140. data/test/test_rake_functional.rb +0 -482
  141. data/test/test_rake_invocation_chain.rb +0 -64
  142. data/test/test_rake_late_time.rb +0 -18
  143. data/test/test_rake_linked_list.rb +0 -84
  144. data/test/test_rake_makefile_loader.rb +0 -46
  145. data/test/test_rake_multi_task.rb +0 -64
  146. data/test/test_rake_name_space.rb +0 -57
  147. data/test/test_rake_package_task.rb +0 -79
  148. data/test/test_rake_path_map.rb +0 -168
  149. data/test/test_rake_path_map_explode.rb +0 -34
  150. data/test/test_rake_path_map_partial.rb +0 -18
  151. data/test/test_rake_pathname_extensions.rb +0 -15
  152. data/test/test_rake_pseudo_status.rb +0 -21
  153. data/test/test_rake_rake_test_loader.rb +0 -20
  154. data/test/test_rake_reduce_compat.rb +0 -26
  155. data/test/test_rake_require.rb +0 -40
  156. data/test/test_rake_rules.rb +0 -388
  157. data/test/test_rake_scope.rb +0 -44
  158. data/test/test_rake_task.rb +0 -393
  159. data/test/test_rake_task_argument_parsing.rb +0 -119
  160. data/test/test_rake_task_arguments.rb +0 -127
  161. data/test/test_rake_task_lib.rb +0 -9
  162. data/test/test_rake_task_manager.rb +0 -178
  163. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  164. data/test/test_rake_task_with_arguments.rb +0 -172
  165. data/test/test_rake_test_task.rb +0 -146
  166. data/test/test_rake_thread_pool.rb +0 -145
  167. data/test/test_rake_top_level_functions.rb +0 -71
  168. data/test/test_rake_win32.rb +0 -72
  169. data/test/test_thread_history_display.rb +0 -101
  170. data/test/test_trace_output.rb +0 -52
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Default Rakefile loader used by +import+.
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  # Rake DSL functions.
2
- require 'rake/file_utils_ext'
3
+ require "rake/file_utils_ext"
3
4
 
4
5
  module Rake
5
6
 
@@ -25,10 +26,9 @@ module Rake
25
26
  private
26
27
 
27
28
  # :call-seq:
28
- # task task_name
29
- # task task_name: dependencies
30
- # task task_name, arguments => dependencies
31
- # task task_name, argument[, argument ...], :needs: dependencies
29
+ # task(task_name)
30
+ # task(task_name: dependencies)
31
+ # task(task_name, arguments => dependencies)
32
32
  #
33
33
  # Declare a basic task. The +task_name+ is always the first argument. If
34
34
  # the task name contains a ":" it is defined in that namespace.
@@ -56,12 +56,6 @@ module Rake
56
56
  #
57
57
  # $ rake package[1.2.3]
58
58
  #
59
- # Alternate definition:
60
- #
61
- # task :package, :version, needs: :test do |t, args|
62
- # # ...
63
- # end
64
- #
65
59
  def task(*args, &block) # :doc:
66
60
  Rake::Task.define_task(*args, &block)
67
61
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # EarlyTime is a fake timestamp that occurs _before_ any other time value.
data/lib/rake/ext/core.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Module
2
3
  # Check for an existing method in the current class before extending. If
3
4
  # the method already exists, then a warning is printed and the extension is
@@ -1,4 +1,5 @@
1
- require 'rake/ext/core'
1
+ # frozen_string_literal: true
2
+ require "rake/ext/core"
2
3
 
3
4
  class String
4
5
 
@@ -10,9 +11,9 @@ class String
10
11
  # +ext+ is a user added method for the String class.
11
12
  #
12
13
  # This String extension comes from Rake
13
- def ext(newext='')
14
- return self.dup if ['.', '..'].include? self
15
- if newext != ''
14
+ def ext(newext="")
15
+ return self.dup if [".", ".."].include? self
16
+ if newext != ""
16
17
  newext = "." + newext unless newext =~ /^\./
17
18
  end
18
19
  self.chomp(File.extname(self)) << newext
@@ -26,8 +27,8 @@ class String
26
27
  def pathmap_explode
27
28
  head, tail = File.split(self)
28
29
  return [self] if head == self
29
- return [tail] if head == '.' || tail == '/'
30
- return [head, tail] if head == '/'
30
+ return [tail] if head == "." || tail == "/"
31
+ return [head, tail] if head == "/"
31
32
  return head.pathmap_explode + [tail]
32
33
  end
33
34
  protected :pathmap_explode
@@ -57,15 +58,15 @@ class String
57
58
  # This String extension comes from Rake
58
59
  def pathmap_replace(patterns, &block)
59
60
  result = self
60
- patterns.split(';').each do |pair|
61
- pattern, replacement = pair.split(',')
61
+ patterns.split(";").each do |pair|
62
+ pattern, replacement = pair.split(",")
62
63
  pattern = Regexp.new(pattern)
63
- if replacement == '*' && block_given?
64
+ if replacement == "*" && block_given?
64
65
  result = result.sub(pattern, &block)
65
66
  elsif replacement
66
67
  result = result.sub(pattern, replacement)
67
68
  else
68
- result = result.sub(pattern, '')
69
+ result = result.sub(pattern, "")
69
70
  end
70
71
  end
71
72
  result
@@ -136,32 +137,32 @@ class String
136
137
  # This String extension comes from Rake
137
138
  def pathmap(spec=nil, &block)
138
139
  return self if spec.nil?
139
- result = ''
140
+ result = "".dup
140
141
  spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
141
142
  case frag
142
- when '%f'
143
+ when "%f"
143
144
  result << File.basename(self)
144
- when '%n'
145
+ when "%n"
145
146
  result << File.basename(self).ext
146
- when '%d'
147
+ when "%d"
147
148
  result << File.dirname(self)
148
- when '%x'
149
+ when "%x"
149
150
  result << File.extname(self)
150
- when '%X'
151
+ when "%X"
151
152
  result << self.ext
152
- when '%p'
153
+ when "%p"
153
154
  result << self
154
- when '%s'
155
+ when "%s"
155
156
  result << (File::ALT_SEPARATOR || File::SEPARATOR)
156
- when '%-'
157
+ when "%-"
157
158
  # do nothing
158
- when '%%'
159
+ when "%%"
159
160
  result << "%"
160
161
  when /%(-?\d+)d/
161
162
  result << pathmap_partial($1.to_i)
162
163
  when /^%\{([^}]*)\}(\d*[dpfnxX])/
163
164
  patterns, operator = $1, $2
164
- result << pathmap('%' + operator).pathmap_replace(patterns, &block)
165
+ result << pathmap("%" + operator).pathmap_replace(patterns, &block)
165
166
  when /^%/
166
167
  fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
167
168
  else
@@ -1,5 +1,6 @@
1
- require 'rake/file_task'
2
- require 'rake/early_time'
1
+ # frozen_string_literal: true
2
+ require "rake/file_task"
3
+ require "rake/early_time"
3
4
 
4
5
  module Rake
5
6
 
@@ -11,7 +12,7 @@ module Rake
11
12
  class FileCreationTask < FileTask
12
13
  # Is this file task needed? Yes if it doesn't exist.
13
14
  def needed?
14
- ! File.exist?(name)
15
+ !File.exist?(name)
15
16
  end
16
17
 
17
18
  # Time stamp for file creation task. This time stamp is earlier
@@ -1,7 +1,7 @@
1
- require 'rake/cloneable'
2
- require 'rake/file_utils_ext'
3
- require 'rake/pathmap'
4
-
1
+ # frozen_string_literal: true
2
+ require "rake/cloneable"
3
+ require "rake/file_utils_ext"
4
+ require "rake/ext/string"
5
5
 
6
6
  module Rake
7
7
 
@@ -41,8 +41,7 @@ module Rake
41
41
 
42
42
  # List of array methods (that are not in +Object+) that need to be
43
43
  # delegated.
44
- ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).
45
- map { |n| n.to_s }
44
+ ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map(&:to_s)
46
45
 
47
46
  # List of additional methods that must be delegated.
48
47
  MUST_DEFINE = %w[inspect <=>]
@@ -59,8 +58,7 @@ module Rake
59
58
  + - & |
60
59
  ]
61
60
 
62
- DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).
63
- map { |s| s.to_s }.sort.uniq
61
+ DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).map(&:to_s).sort.uniq
64
62
 
65
63
  # Now do the delegation.
66
64
  DELEGATING_METHODS.each do |sym|
@@ -85,6 +83,8 @@ module Rake
85
83
  end
86
84
  end
87
85
 
86
+ GLOB_PATTERN = %r{[*?\[\{]}
87
+
88
88
  # Create a file list from the globbable patterns given. If you wish to
89
89
  # perform multiple includes or excludes at object build time, use the
90
90
  # "yield self" pattern.
@@ -149,7 +149,11 @@ module Rake
149
149
  #
150
150
  def exclude(*patterns, &block)
151
151
  patterns.each do |pat|
152
- @exclude_patterns << Rake.from_pathname(pat)
152
+ if pat.respond_to? :to_ary
153
+ exclude(*pat.to_ary)
154
+ else
155
+ @exclude_patterns << Rake.from_pathname(pat)
156
+ end
153
157
  end
154
158
  @exclude_procs << block if block_given?
155
159
  resolve_exclude unless @pending
@@ -190,7 +194,7 @@ module Rake
190
194
  result = @items * other
191
195
  case result
192
196
  when Array
193
- FileList.new.import(result)
197
+ self.class.new.import(result)
194
198
  else
195
199
  result
196
200
  end
@@ -215,7 +219,7 @@ module Rake
215
219
 
216
220
  def resolve_add(fn) # :nodoc:
217
221
  case fn
218
- when %r{[*?\[\{]}
222
+ when GLOB_PATTERN
219
223
  add_matching(fn)
220
224
  else
221
225
  self << fn
@@ -236,7 +240,7 @@ module Rake
236
240
  # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
237
241
  #
238
242
  def sub(pat, rep)
239
- inject(FileList.new) { |res, fn| res << fn.sub(pat, rep) }
243
+ inject(self.class.new) { |res, fn| res << fn.sub(pat, rep) }
240
244
  end
241
245
 
242
246
  # Return a new FileList with the results of running +gsub+ against each
@@ -247,7 +251,7 @@ module Rake
247
251
  # => ['lib\\test\\file', 'x\\y']
248
252
  #
249
253
  def gsub(pat, rep)
250
- inject(FileList.new) { |res, fn| res << fn.gsub(pat, rep) }
254
+ inject(self.class.new) { |res, fn| res << fn.gsub(pat, rep) }
251
255
  end
252
256
 
253
257
  # Same as +sub+ except that the original file list is modified.
@@ -265,8 +269,8 @@ module Rake
265
269
  # Apply the pathmap spec to each of the included file names, returning a
266
270
  # new file list with the modified paths. (See String#pathmap for
267
271
  # details.)
268
- def pathmap(spec=nil)
269
- collect { |fn| fn.pathmap(spec) }
272
+ def pathmap(spec=nil, &block)
273
+ collect { |fn| fn.pathmap(spec, &block) }
270
274
  end
271
275
 
272
276
  # Return a new FileList with <tt>String#ext</tt> method applied to
@@ -277,7 +281,7 @@ module Rake
277
281
  # array.collect { |item| item.ext(newext) }
278
282
  #
279
283
  # +ext+ is a user added method for the Array class.
280
- def ext(newext='')
284
+ def ext(newext="")
281
285
  collect { |fn| fn.ext(newext) }
282
286
  end
283
287
 
@@ -290,7 +294,7 @@ module Rake
290
294
  matched = 0
291
295
  each do |fn|
292
296
  begin
293
- open(fn, "r", *options) do |inf|
297
+ File.open(fn, "r", *options) do |inf|
294
298
  count = 0
295
299
  inf.each do |line|
296
300
  count += 1
@@ -314,14 +318,14 @@ module Rake
314
318
  # Return a new file list that only contains file names from the current
315
319
  # file list that exist on the file system.
316
320
  def existing
317
- select { |fn| File.exist?(fn) }
321
+ select { |fn| File.exist?(fn) }.uniq
318
322
  end
319
323
 
320
324
  # Modify the current file list so that it contains only file name that
321
325
  # exist on the file system.
322
326
  def existing!
323
327
  resolve
324
- @items = @items.select { |fn| File.exist?(fn) }
328
+ @items = @items.select { |fn| File.exist?(fn) }.uniq
325
329
  self
326
330
  end
327
331
 
@@ -331,20 +335,20 @@ module Rake
331
335
  resolve
332
336
  result = @items.partition(&block)
333
337
  [
334
- FileList.new.import(result[0]),
335
- FileList.new.import(result[1]),
338
+ self.class.new.import(result[0]),
339
+ self.class.new.import(result[1]),
336
340
  ]
337
341
  end
338
342
 
339
343
  # Convert a FileList to a string by joining all elements with a space.
340
344
  def to_s
341
345
  resolve
342
- self.join(' ')
346
+ self.join(" ")
343
347
  end
344
348
 
345
349
  # Add matching glob patterns.
346
350
  def add_matching(pattern)
347
- FileList.glob(pattern).each do |fn|
351
+ self.class.glob(pattern).each do |fn|
348
352
  self << fn unless excluded_from_list?(fn)
349
353
  end
350
354
  end
@@ -362,8 +366,11 @@ module Rake
362
366
  case pat
363
367
  when Regexp
364
368
  fn =~ pat
365
- when /[*?]/
366
- File.fnmatch?(pat, fn, File::FNM_PATHNAME)
369
+ when GLOB_PATTERN
370
+ flags = File::FNM_PATHNAME
371
+ # Ruby <= 1.9.3 does not support File::FNM_EXTGLOB
372
+ flags |= File::FNM_EXTGLOB if defined? File::FNM_EXTGLOB
373
+ File.fnmatch?(pat, fn, flags)
367
374
  else
368
375
  fn == pat
369
376
  end
@@ -378,7 +385,7 @@ module Rake
378
385
  /~$/
379
386
  ]
380
387
  DEFAULT_IGNORE_PROCS = [
381
- proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) }
388
+ proc { |fn| fn =~ /(^|[\/\\])core$/ && !File.directory?(fn) }
382
389
  ]
383
390
 
384
391
  def import(array) # :nodoc:
@@ -410,7 +417,7 @@ module Rake
410
417
  # Yield each file or directory component.
411
418
  def each_dir_parent(dir) # :nodoc:
412
419
  old_length = nil
413
- while dir != '.' && dir.length != old_length
420
+ while dir != "." && dir.length != old_length
414
421
  yield(dir)
415
422
  old_length = dir.length
416
423
  dir = File.dirname(dir)
@@ -1,5 +1,6 @@
1
- require 'rake/task.rb'
2
- require 'rake/early_time'
1
+ # frozen_string_literal: true
2
+ require "rake/task"
3
+ require "rake/early_time"
3
4
 
4
5
  module Rake
5
6
 
@@ -13,7 +14,7 @@ module Rake
13
14
  # Is this file task needed? Yes if it doesn't exist, or if its time stamp
14
15
  # is out of date.
15
16
  def needed?
16
- ! File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
17
+ !File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
17
18
  end
18
19
 
19
20
  # Time stamp for file task.
@@ -29,7 +30,14 @@ module Rake
29
30
 
30
31
  # Are there any prerequisites with a later time than the given time stamp?
31
32
  def out_of_date?(stamp)
32
- @prerequisites.any? { |n| application[n, @scope].timestamp > stamp }
33
+ all_prerequisite_tasks.any? { |prereq|
34
+ prereq_task = application[prereq, @scope]
35
+ if prereq_task.instance_of?(Rake::FileTask)
36
+ prereq_task.timestamp > stamp || @application.options.build_all
37
+ else
38
+ prereq_task.timestamp > stamp
39
+ end
40
+ }
33
41
  end
34
42
 
35
43
  # ----------------------------------------------------------------
@@ -1,19 +1,17 @@
1
- require 'rbconfig'
2
- require 'fileutils'
1
+ # frozen_string_literal: true
2
+ require "rbconfig"
3
+ require "fileutils"
3
4
 
4
5
  #--
5
6
  # This a FileUtils extension that defines several additional commands to be
6
7
  # added to the FileUtils utility functions.
7
8
  module FileUtils
8
9
  # Path to the currently running Ruby program
9
- RUBY = ENV['RUBY'] || File.join(
10
- RbConfig::CONFIG['bindir'],
11
- RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).
10
+ RUBY = ENV["RUBY"] || File.join(
11
+ RbConfig::CONFIG["bindir"],
12
+ RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]).
12
13
  sub(/.*\s.*/m, '"\&"')
13
14
 
14
- OPT_TABLE['sh'] = %w(noop verbose)
15
- OPT_TABLE['ruby'] = %w(noop verbose)
16
-
17
15
  # Run the system command +cmd+. If multiple arguments are given the command
18
16
  # is run directly (without the shell, same semantics as Kernel::exec and
19
17
  # Kernel::system).
@@ -37,7 +35,7 @@ module FileUtils
37
35
  #
38
36
  # # check exit status after command runs
39
37
  # sh %{grep pattern file} do |ok, res|
40
- # if ! ok
38
+ # if !ok
41
39
  # puts "pattern not found (status = #{res.exitstatus})"
42
40
  # end
43
41
  # end
@@ -45,13 +43,15 @@ module FileUtils
45
43
  def sh(*cmd, &block)
46
44
  options = (Hash === cmd.last) ? cmd.pop : {}
47
45
  shell_runner = block_given? ? block : create_shell_runner(cmd)
46
+
48
47
  set_verbose_option(options)
49
- options[:noop] ||= Rake::FileUtilsExt.nowrite_flag
50
- Rake.rake_check_options options, :noop, :verbose
51
- Rake.rake_output_message cmd.join(" ") if options[:verbose]
48
+ verbose = options.delete :verbose
49
+ noop = options.delete(:noop) || Rake::FileUtilsExt.nowrite_flag
50
+
51
+ Rake.rake_output_message sh_show_command cmd if verbose
52
52
 
53
- unless options[:noop]
54
- res = rake_system(*cmd)
53
+ unless noop
54
+ res = (Hash === cmd.last) ? system(*cmd) : system(*cmd, options)
55
55
  status = $?
56
56
  status = Rake::PseudoStatus.new(1) if !res && status.nil?
57
57
  shell_runner.call(res, status)
@@ -59,8 +59,9 @@ module FileUtils
59
59
  end
60
60
 
61
61
  def create_shell_runner(cmd) # :nodoc:
62
- show_command = cmd.join(" ")
62
+ show_command = sh_show_command cmd
63
63
  show_command = show_command[0, 42] + "..." unless $trace
64
+
64
65
  lambda do |ok, status|
65
66
  ok or
66
67
  fail "Command failed with status (#{status.exitstatus}): " +
@@ -69,6 +70,19 @@ module FileUtils
69
70
  end
70
71
  private :create_shell_runner
71
72
 
73
+ def sh_show_command(cmd) # :nodoc:
74
+ cmd = cmd.dup
75
+
76
+ if Hash === cmd.first
77
+ env = cmd.first
78
+ env = env.map { |name, value| "#{name}=#{value}" }.join " "
79
+ cmd[0] = env
80
+ end
81
+
82
+ cmd.join " "
83
+ end
84
+ private :sh_show_command
85
+
72
86
  def set_verbose_option(options) # :nodoc:
73
87
  unless options.key? :verbose
74
88
  options[:verbose] =
@@ -78,22 +92,16 @@ module FileUtils
78
92
  end
79
93
  private :set_verbose_option
80
94
 
81
- def rake_system(*cmd) # :nodoc:
82
- Rake::AltSystem.system(*cmd)
83
- end
84
- private :rake_system
85
-
86
95
  # Run a Ruby interpreter with the given arguments.
87
96
  #
88
97
  # Example:
89
98
  # ruby %{-pe '$_.upcase!' <README}
90
99
  #
91
- def ruby(*args, &block)
92
- options = (Hash === args.last) ? args.pop : {}
100
+ def ruby(*args, **options, &block)
93
101
  if args.length > 1
94
- sh(*([RUBY] + args + [options]), &block)
102
+ sh(RUBY, *args, **options, &block)
95
103
  else
96
- sh("#{RUBY} #{args.first}", options, &block)
104
+ sh("#{RUBY} #{args.first}", **options, &block)
97
105
  end
98
106
  end
99
107
 
@@ -101,17 +109,15 @@ module FileUtils
101
109
 
102
110
  # Attempt to do a normal file link, but fall back to a copy if the link
103
111
  # fails.
104
- def safe_ln(*args)
105
- if ! LN_SUPPORTED[0]
106
- cp(*args)
107
- else
112
+ def safe_ln(*args, **options)
113
+ if LN_SUPPORTED[0]
108
114
  begin
109
- ln(*args)
115
+ return options.empty? ? ln(*args) : ln(*args, **options)
110
116
  rescue StandardError, NotImplementedError
111
117
  LN_SUPPORTED[0] = false
112
- cp(*args)
113
118
  end
114
119
  end
120
+ options.empty? ? cp(*args) : cp(*args, **options)
115
121
  end
116
122
 
117
123
  # Split a file path into individual directory names.
@@ -121,8 +127,8 @@ module FileUtils
121
127
  #
122
128
  def split_all(path)
123
129
  head, tail = File.split(path)
124
- return [tail] if head == '.' || tail == '/'
125
- return [head, tail] if head == '/'
130
+ return [tail] if head == "." || tail == "/"
131
+ return [head, tail] if head == "/"
126
132
  return split_all(head) + [tail]
127
133
  end
128
134
  end
@@ -1,4 +1,5 @@
1
- require 'rake/file_utils'
1
+ # frozen_string_literal: true
2
+ require "rake/file_utils"
2
3
 
3
4
  module Rake
4
5
  #
@@ -22,19 +23,18 @@ module Rake
22
23
  opts = FileUtils.options_of name
23
24
  default_options = []
24
25
  if opts.include?("verbose")
25
- default_options << ':verbose => FileUtilsExt.verbose_flag'
26
+ default_options << "verbose: FileUtilsExt.verbose_flag"
26
27
  end
27
28
  if opts.include?("noop")
28
- default_options << ':noop => FileUtilsExt.nowrite_flag'
29
+ default_options << "noop: FileUtilsExt.nowrite_flag"
29
30
  end
30
31
 
31
32
  next if default_options.empty?
32
33
  module_eval(<<-EOS, __FILE__, __LINE__ + 1)
33
- def #{name}( *args, &block )
34
- super(
35
- *rake_merge_option(args,
36
- #{default_options.join(', ')}
37
- ), &block)
34
+ def #{name}(*args, **options, &block)
35
+ super(*args,
36
+ #{default_options.join(', ')},
37
+ **options, &block)
38
38
  end
39
39
  EOS
40
40
  end
@@ -112,16 +112,6 @@ module Rake
112
112
  end
113
113
  end
114
114
 
115
- # Merge the given options with the default values.
116
- def rake_merge_option(args, defaults)
117
- if Hash === args.last
118
- defaults.update(args.last)
119
- args.pop
120
- end
121
- args.push defaults
122
- args
123
- end
124
-
125
115
  # Send the message to the default rake output (which is $stderr).
126
116
  def rake_output_message(message)
127
117
  $stderr.puts(message)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # InvocationChain tracks the chain of task invocations to detect
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
  module InvocationExceptionMixin
3
4
  # Return the invocation chain (list of Rake tasks) that were in
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
  # LateTime is a fake timestamp that occurs _after_ any other time value.
3
4
  class LateTime
@@ -9,7 +10,7 @@ module Rake
9
10
  end
10
11
 
11
12
  def to_s
12
- '<LATE TIME>'
13
+ "<LATE TIME>"
13
14
  end
14
15
  end
15
16