rake 12.0.0.beta1 → 13.0.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) 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 +11 -4
  7. data/Gemfile +7 -0
  8. data/History.rdoc +124 -11
  9. data/README.rdoc +7 -8
  10. data/Rakefile +7 -4
  11. data/bin/bundle +105 -0
  12. data/bin/rake +29 -0
  13. data/bin/rdoc +29 -0
  14. data/bin/rubocop +29 -0
  15. data/doc/jamis.rb +1 -0
  16. data/doc/rakefile.rdoc +1 -1
  17. data/lib/rake.rb +1 -0
  18. data/lib/rake/application.rb +54 -15
  19. data/lib/rake/backtrace.rb +1 -0
  20. data/lib/rake/clean.rb +4 -3
  21. data/lib/rake/cloneable.rb +1 -0
  22. data/lib/rake/cpu_counter.rb +2 -1
  23. data/lib/rake/default_loader.rb +1 -0
  24. data/lib/rake/dsl_definition.rb +4 -3
  25. data/lib/rake/early_time.rb +1 -0
  26. data/lib/rake/ext/core.rb +1 -0
  27. data/lib/rake/ext/string.rb +2 -1
  28. data/lib/rake/file_creation_task.rb +2 -1
  29. data/lib/rake/file_list.rb +5 -4
  30. data/lib/rake/file_task.rb +11 -3
  31. data/lib/rake/file_utils.rb +10 -12
  32. data/lib/rake/file_utils_ext.rb +7 -17
  33. data/lib/rake/invocation_chain.rb +1 -0
  34. data/lib/rake/invocation_exception_mixin.rb +1 -0
  35. data/lib/rake/late_time.rb +1 -0
  36. data/lib/rake/linked_list.rb +1 -0
  37. data/lib/rake/loaders/makefile.rb +1 -0
  38. data/lib/rake/multi_task.rb +2 -37
  39. data/lib/rake/name_space.rb +1 -0
  40. data/lib/rake/packagetask.rb +18 -6
  41. data/lib/rake/phony.rb +1 -0
  42. data/lib/rake/private_reader.rb +1 -0
  43. data/lib/rake/promise.rb +3 -2
  44. data/lib/rake/pseudo_status.rb +1 -0
  45. data/lib/rake/rake_module.rb +29 -0
  46. data/lib/rake/rake_test_loader.rb +17 -11
  47. data/lib/rake/rule_recursion_overflow_error.rb +1 -0
  48. data/lib/rake/scope.rb +2 -1
  49. data/lib/rake/task.rb +59 -16
  50. data/lib/rake/task_argument_error.rb +1 -0
  51. data/lib/rake/task_arguments.rb +2 -0
  52. data/lib/rake/task_manager.rb +42 -17
  53. data/lib/rake/tasklib.rb +1 -0
  54. data/lib/rake/testtask.rb +3 -1
  55. data/lib/rake/thread_history_display.rb +1 -0
  56. data/lib/rake/thread_pool.rb +1 -0
  57. data/lib/rake/trace_output.rb +1 -0
  58. data/lib/rake/version.rb +2 -1
  59. data/lib/rake/win32.rb +1 -0
  60. data/rake.gemspec +4 -7
  61. metadata +13 -52
  62. data/.gitignore +0 -14
  63. data/.rubocop.yml +0 -57
  64. data/.travis.yml +0 -21
  65. data/appveyor.yml +0 -21
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "rake/file_utils"
2
3
 
3
4
  module Rake
@@ -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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Polylithic linked list structure used to implement several data
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Makefile loader to be used with the import file loader. Use this to
@@ -1,49 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Same as a regular task, but the immediate prerequisites are done in
4
5
  # parallel using Ruby threads.
5
6
  #
6
7
  class MultiTask < Task
7
-
8
- # Same as invoke, but explicitly pass a call chain to detect
9
- # circular dependencies. This is largely copied from Rake::Task
10
- # but has been updated such that if multiple tasks depend on this
11
- # one in parallel, they will all fail if the first execution of
12
- # this task fails.
13
- def invoke_with_call_chain(task_args, invocation_chain)
14
- new_chain = Rake::InvocationChain.append(self, invocation_chain)
15
- @lock.synchronize do
16
- begin
17
- if @already_invoked
18
- if @invocation_exception
19
- if application.options.trace
20
- application.trace "** Previous invocation of #{name} failed #{format_trace_flags}"
21
- end
22
- raise @invocation_exception
23
- else
24
- return
25
- end
26
- end
27
-
28
- if application.options.trace
29
- application.trace "** Invoke #{name} #{format_trace_flags}"
30
- end
31
- @already_invoked = true
32
-
33
- invoke_prerequisites(task_args, new_chain)
34
- execute(task_args) if needed?
35
- rescue Exception => ex
36
- add_chain_to(ex, new_chain)
37
- @invocation_exception = ex
38
- raise
39
- end
40
- end
41
- end
42
-
43
8
  private
9
+
44
10
  def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
45
11
  invoke_prerequisites_concurrently(task_args, invocation_chain)
46
12
  end
47
13
  end
48
-
49
14
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # The NameSpace class will lookup task names in the scope defined by a
3
4
  # +namespace+ command.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Define a package task library to aid in the definition of
2
3
  # redistributable package files.
3
4
 
@@ -78,6 +79,9 @@ module Rake
78
79
  # Zip command for zipped archives. The default is 'zip'.
79
80
  attr_accessor :zip_command
80
81
 
82
+ # True if parent directory should be omited (default is false)
83
+ attr_accessor :without_parent_dir
84
+
81
85
  # Create a Package Task with the given name and version. Use +:noversion+
82
86
  # as the version to build a package without a version or to provide a
83
87
  # fully-versioned package name.
@@ -101,6 +105,7 @@ module Rake
101
105
  @need_zip = false
102
106
  @tar_command = "tar"
103
107
  @zip_command = "zip"
108
+ @without_parent_dir = false
104
109
  end
105
110
 
106
111
  # Create the tasks defined by this task library.
@@ -131,9 +136,8 @@ module Rake
131
136
  task package: ["#{package_dir}/#{file}"]
132
137
  file "#{package_dir}/#{file}" =>
133
138
  [package_dir_path] + package_files do
134
- chdir(package_dir) do
135
- sh @tar_command, "#{flag}cvf", file, package_name
136
- end
139
+ chdir(working_dir) { sh @tar_command, "#{flag}cvf", file, target_dir }
140
+ mv "#{package_dir_path}/#{target_dir}", package_dir if without_parent_dir
137
141
  end
138
142
  end
139
143
  end
@@ -142,9 +146,8 @@ module Rake
142
146
  task package: ["#{package_dir}/#{zip_file}"]
143
147
  file "#{package_dir}/#{zip_file}" =>
144
148
  [package_dir_path] + package_files do
145
- chdir(package_dir) do
146
- sh @zip_command, "-r", zip_file, package_name
147
- end
149
+ chdir(working_dir) { sh @zip_command, "-r", zip_file, target_dir }
150
+ mv "#{package_dir_path}/#{zip_file}", package_dir if without_parent_dir
148
151
  end
149
152
  end
150
153
 
@@ -205,6 +208,15 @@ module Rake
205
208
  def zip_file
206
209
  "#{package_name}.zip"
207
210
  end
211
+
212
+ def working_dir
213
+ without_parent_dir ? package_dir_path : package_dir
214
+ end
215
+
216
+ # target directory relative to working_dir
217
+ def target_dir
218
+ without_parent_dir ? "." : package_name
219
+ end
208
220
  end
209
221
 
210
222
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Defines a :phony task that you can use as a dependency. This allows
2
3
  # file-based tasks to use non-file-based tasks as prerequisites
3
4
  # without forcing them to rebuild.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Include PrivateReader to use +private_reader+.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # A Promise object represents a promise to do work (a chore) in the
@@ -70,12 +71,12 @@ module Rake
70
71
 
71
72
  # Do we have a result for the promise
72
73
  def result?
73
- ! @result.equal?(NOT_SET)
74
+ !@result.equal?(NOT_SET)
74
75
  end
75
76
 
76
77
  # Did the promise throw an error
77
78
  def error?
78
- ! @error.equal?(NOT_SET)
79
+ !@error.equal?(NOT_SET)
79
80
  end
80
81
 
81
82
  # Are we done with the promise
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "rake/application"
2
3
 
3
4
  module Rake
@@ -33,6 +34,34 @@ module Rake
33
34
  application.options.rakelib ||= []
34
35
  application.options.rakelib.concat(files)
35
36
  end
37
+
38
+ # Make +block_application+ the default rake application inside a block so
39
+ # you can load rakefiles into a different application.
40
+ #
41
+ # This is useful when you want to run rake tasks inside a library without
42
+ # running rake in a sub-shell.
43
+ #
44
+ # Example:
45
+ #
46
+ # Dir.chdir 'other/directory'
47
+ #
48
+ # other_rake = Rake.with_application do |rake|
49
+ # rake.load_rakefile
50
+ # end
51
+ #
52
+ # puts other_rake.tasks
53
+
54
+ def with_application(block_application = Rake::Application.new)
55
+ orig_application = Rake.application
56
+
57
+ Rake.application = block_application
58
+
59
+ yield block_application
60
+
61
+ block_application
62
+ ensure
63
+ Rake.application = orig_application
64
+ end
36
65
  end
37
66
 
38
67
  end
@@ -1,20 +1,26 @@
1
+ # frozen_string_literal: true
1
2
  require "rake"
2
3
 
3
4
  # Load the test files from the command line.
4
5
  argv = ARGV.select do |argument|
5
- case argument
6
- when /^-/ then
7
- argument
8
- when /\*/ then
9
- FileList[argument].to_a.each do |file|
10
- require File.expand_path file
11
- end
6
+ begin
7
+ case argument
8
+ when /^-/ then
9
+ argument
10
+ when /\*/ then
11
+ FileList[argument].to_a.each do |file|
12
+ require File.expand_path file
13
+ end
12
14
 
13
- false
14
- else
15
- require File.expand_path argument
15
+ false
16
+ else
17
+ require File.expand_path argument
16
18
 
17
- false
19
+ false
20
+ end
21
+ rescue LoadError => e
22
+ raise unless e.path
23
+ abort "\nFile does not exist: #{e.path}\n\n"
18
24
  end
19
25
  end
20
26
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Error indicating a recursion overflow error in task selection.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
  class Scope < LinkedList # :nodoc: all
3
4
 
@@ -15,7 +16,7 @@ module Rake
15
16
  # this trim beyond the toplevel scope.
16
17
  def trim(n)
17
18
  result = self
18
- while n > 0 && ! result.empty?
19
+ while n > 0 && !result.empty?
19
20
  result = result.tail
20
21
  n -= 1
21
22
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "rake/invocation_exception_mixin"
2
3
 
3
4
  module Rake
@@ -14,6 +15,10 @@ module Rake
14
15
  class Task
15
16
  # List of prerequisites for a task.
16
17
  attr_reader :prerequisites
18
+ alias prereqs prerequisites
19
+
20
+ # List of order only prerequisites for a task.
21
+ attr_reader :order_only_prerequisites
17
22
 
18
23
  # List of actions attached to a task.
19
24
  attr_reader :actions
@@ -54,7 +59,7 @@ module Rake
54
59
 
55
60
  # List of prerequisite tasks
56
61
  def prerequisite_tasks
57
- prerequisites.map { |pre| lookup_prerequisite(pre) }
62
+ (prerequisites + order_only_prerequisites).map { |pre| lookup_prerequisite(pre) }
58
63
  end
59
64
 
60
65
  def lookup_prerequisite(prerequisite_name) # :nodoc:
@@ -102,6 +107,8 @@ module Rake
102
107
  @scope = app.current_scope
103
108
  @arg_names = nil
104
109
  @locations = []
110
+ @invocation_exception = nil
111
+ @order_only_prerequisites = []
105
112
  end
106
113
 
107
114
  # Enhance a task with prerequisites or actions. Returns self.
@@ -182,20 +189,39 @@ module Rake
182
189
 
183
190
  # Same as invoke, but explicitly pass a call chain to detect
184
191
  # circular dependencies.
185
- def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
186
- new_chain = InvocationChain.append(self, invocation_chain)
192
+ #
193
+ # If multiple tasks depend on this
194
+ # one in parallel, they will all fail if the first execution of
195
+ # this task fails.
196
+ def invoke_with_call_chain(task_args, invocation_chain)
197
+ new_chain = Rake::InvocationChain.append(self, invocation_chain)
187
198
  @lock.synchronize do
188
- if application.options.trace
189
- application.trace "** Invoke #{name} #{format_trace_flags}"
199
+ begin
200
+ if application.options.trace
201
+ application.trace "** Invoke #{name} #{format_trace_flags}"
202
+ end
203
+
204
+ if @already_invoked
205
+ if @invocation_exception
206
+ if application.options.trace
207
+ application.trace "** Previous invocation of #{name} failed #{format_trace_flags}"
208
+ end
209
+ raise @invocation_exception
210
+ else
211
+ return
212
+ end
213
+ end
214
+
215
+ @already_invoked = true
216
+
217
+ invoke_prerequisites(task_args, new_chain)
218
+ execute(task_args) if needed?
219
+ rescue Exception => ex
220
+ add_chain_to(ex, new_chain)
221
+ @invocation_exception = ex
222
+ raise ex
190
223
  end
191
- return if @already_invoked
192
- @already_invoked = true
193
- invoke_prerequisites(task_args, new_chain)
194
- execute(task_args) if needed?
195
224
  end
196
- rescue Exception => ex
197
- add_chain_to(ex, new_chain)
198
- raise ex
199
225
  end
200
226
  protected :invoke_with_call_chain
201
227
 
@@ -226,7 +252,8 @@ module Rake
226
252
  r.invoke_with_call_chain(prereq_args, invocation_chain)
227
253
  end
228
254
  end
229
- futures.each(&:value)
255
+ # Iterate in reverse to improve performance related to thread waiting and switching
256
+ futures.reverse_each(&:value)
230
257
  end
231
258
 
232
259
  # Format the trace flags for display.
@@ -247,7 +274,11 @@ module Rake
247
274
  end
248
275
  application.trace "** Execute #{name}" if application.options.trace
249
276
  application.enhance_with_matching_rule(name) if @actions.empty?
250
- @actions.each { |act| act.call(self, args) }
277
+ if opts = Hash.try_convert(args) and !opts.empty?
278
+ @actions.each { |act| act.call(self, args, **opts)}
279
+ else
280
+ @actions.each { |act| act.call(self, args)}
281
+ end
251
282
  end
252
283
 
253
284
  # Is this task needed?
@@ -266,7 +297,7 @@ module Rake
266
297
  def add_description(description)
267
298
  return unless description
268
299
  comment = description.strip
269
- add_comment(comment) if comment && ! comment.empty?
300
+ add_comment(comment) if comment && !comment.empty?
270
301
  end
271
302
 
272
303
  def comment=(comment) # :nodoc:
@@ -320,7 +351,7 @@ module Rake
320
351
  # Return a string describing the internal state of a task. Useful for
321
352
  # debugging.
322
353
  def investigation
323
- result = "------------------------------\n"
354
+ result = "------------------------------\n".dup
324
355
  result << "Investigating #{name}\n"
325
356
  result << "class: #{self.class}\n"
326
357
  result << "task needed: #{needed?}\n"
@@ -337,6 +368,18 @@ module Rake
337
368
  return result
338
369
  end
339
370
 
371
+ # Format dependencies parameter to pass to task.
372
+ def self.format_deps(deps)
373
+ deps = [deps] unless deps.respond_to?(:to_ary)
374
+ deps.map { |d| Rake.from_pathname(d).to_s }
375
+ end
376
+
377
+ # Add order only dependencies.
378
+ def |(deps)
379
+ @order_only_prerequisites |= Task.format_deps(deps) - @prerequisites
380
+ self
381
+ end
382
+
340
383
  # ----------------------------------------------------------------
341
384
  # Rake Module Methods
342
385
  #