rake 10.5.0 → 13.0.6

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 +131 -90
  9. data/lib/rake/backtrace.rb +3 -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 +5 -11
  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 +12 -4
  21. data/lib/rake/file_utils.rb +38 -32
  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 +35 -43
  51. data/rake.gemspec +100 -0
  52. metadata +27 -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,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Based on a script at:
@@ -14,7 +15,7 @@ module Rake
14
15
  end
15
16
 
16
17
  begin
17
- require 'etc'
18
+ require "etc"
18
19
  rescue LoadError
19
20
  else
20
21
  if Etc.respond_to?(:nprocessors)
@@ -30,31 +31,22 @@ unless Rake::CpuCounter.method_defined?(:count)
30
31
  Rake::CpuCounter.class_eval <<-'end;', __FILE__, __LINE__+1
31
32
  require 'rbconfig'
32
33
 
33
- # TODO: replace with IO.popen using array-style arguments in Rake 11
34
- require 'open3'
35
-
36
34
  def count
37
- if defined?(Java::Java)
35
+ if RUBY_PLATFORM == 'java'
38
36
  count_via_java_runtime
39
37
  else
40
38
  case RbConfig::CONFIG['host_os']
41
- when /darwin9/
42
- count_via_hwprefs_cpu_count
43
- when /darwin/
44
- count_via_hwprefs_thread_count || count_via_sysctl
45
39
  when /linux/
46
40
  count_via_cpuinfo
47
- when /bsd/
41
+ when /darwin|bsd/
48
42
  count_via_sysctl
49
43
  when /mswin|mingw/
50
44
  count_via_win32
51
45
  else
52
46
  # Try everything
53
47
  count_via_win32 ||
54
- count_via_sysctl ||
55
- count_via_hwprefs_thread_count ||
56
- count_via_hwprefs_cpu_count ||
57
- count_via_cpuinfo
48
+ count_via_sysctl ||
49
+ count_via_cpuinfo
58
50
  end
59
51
  end
60
52
  end
@@ -80,14 +72,6 @@ unless Rake::CpuCounter.method_defined?(:count)
80
72
  nil
81
73
  end
82
74
 
83
- def count_via_hwprefs_thread_count
84
- run 'hwprefs', 'thread_count'
85
- end
86
-
87
- def count_via_hwprefs_cpu_count
88
- run 'hwprefs', 'cpu_count'
89
- end
90
-
91
75
  def count_via_sysctl
92
76
  run 'sysctl', '-n', 'hw.ncpu'
93
77
  end
@@ -95,10 +79,8 @@ unless Rake::CpuCounter.method_defined?(:count)
95
79
  def run(command, *args)
96
80
  cmd = resolve_command(command)
97
81
  if cmd
98
- Open3.popen3 cmd, *args do |inn, out, err,|
99
- inn.close
100
- err.read
101
- out.read.to_i
82
+ IO.popen [cmd, *args] do |io|
83
+ io.read.to_i
102
84
  end
103
85
  else
104
86
  nil
@@ -117,8 +99,8 @@ unless Rake::CpuCounter.method_defined?(:count)
117
99
  end
118
100
 
119
101
  def in_path_command(command)
120
- Open3.popen3 'which', command do |_, out,|
121
- out.eof? ? nil : command
102
+ IO.popen ['which', command] do |io|
103
+ io.eof? ? nil : command
122
104
  end
123
105
  end
124
106
  end;
@@ -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