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,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
 
@@ -1,17 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Polylithic linked list structure used to implement several data
4
5
  # structures in Rake.
5
6
  class LinkedList
6
7
  include Enumerable
7
-
8
8
  attr_reader :head, :tail
9
9
 
10
- def initialize(head, tail=EMPTY)
11
- @head = head
12
- @tail = tail
13
- end
14
-
15
10
  # Polymorphically add a new element to the head of a list. The
16
11
  # type of head node will be the same list type as the tail.
17
12
  def conj(item)
@@ -19,6 +14,9 @@ module Rake
19
14
  end
20
15
 
21
16
  # Is the list empty?
17
+ # .make guards against a list being empty making any instantiated LinkedList
18
+ # object not empty by default
19
+ # You should consider overriding this method if you implement your own .make method
22
20
  def empty?
23
21
  false
24
22
  end
@@ -26,7 +24,7 @@ module Rake
26
24
  # Lists are structurally equivalent.
27
25
  def ==(other)
28
26
  current = self
29
- while ! current.empty? && ! other.empty?
27
+ while !current.empty? && !other.empty?
30
28
  return false if current.head != other.head
31
29
  current = current.tail
32
30
  other = other.tail
@@ -36,20 +34,20 @@ module Rake
36
34
 
37
35
  # Convert to string: LL(item, item...)
38
36
  def to_s
39
- items = map { |item| item.to_s }.join(", ")
37
+ items = map(&:to_s).join(", ")
40
38
  "LL(#{items})"
41
39
  end
42
40
 
43
41
  # Same as +to_s+, but with inspected items.
44
42
  def inspect
45
- items = map { |item| item.inspect }.join(", ")
43
+ items = map(&:inspect).join(", ")
46
44
  "LL(#{items})"
47
45
  end
48
46
 
49
47
  # For each item in the list.
50
48
  def each
51
49
  current = self
52
- while ! current.empty?
50
+ while !current.empty?
53
51
  yield(current.head)
54
52
  current = current.tail
55
53
  end
@@ -59,11 +57,16 @@ module Rake
59
57
  # Make a list out of the given arguments. This method is
60
58
  # polymorphic
61
59
  def self.make(*args)
62
- result = empty
63
- args.reverse_each do |item|
64
- result = cons(item, result)
60
+ # return an EmptyLinkedList if there are no arguments
61
+ return empty if !args || args.empty?
62
+
63
+ # build a LinkedList by starting at the tail and iterating
64
+ # through each argument
65
+ # inject takes an EmptyLinkedList to start
66
+ args.reverse.inject(empty) do |list, item|
67
+ list = cons(item, list)
68
+ list # return the newly created list for each item in the block
65
69
  end
66
- result
67
70
  end
68
71
 
69
72
  # Cons a new head onto the tail list.
@@ -76,6 +79,13 @@ module Rake
76
79
  self::EMPTY
77
80
  end
78
81
 
82
+ protected
83
+
84
+ def initialize(head, tail=EMPTY)
85
+ @head = head
86
+ @tail = tail
87
+ end
88
+
79
89
  # Represent an empty list, using the Null Object Pattern.
80
90
  #
81
91
  # When inheriting from the LinkedList class, you should implement
@@ -99,5 +109,4 @@ module Rake
99
109
 
100
110
  EMPTY = EmptyLinkedList.new
101
111
  end
102
-
103
112
  end
@@ -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
@@ -24,7 +25,7 @@ module Rake
24
25
  lines = File.read fn
25
26
  lines.gsub!(/\\ /, SPACE_MARK)
26
27
  lines.gsub!(/#[^\n]*\n/m, "")
27
- lines.gsub!(/\\\n/, ' ')
28
+ lines.gsub!(/\\\n/, " ")
28
29
  lines.each_line do |line|
29
30
  process_line(line)
30
31
  end
@@ -34,7 +35,7 @@ module Rake
34
35
 
35
36
  # Process one logical line of makefile data.
36
37
  def process_line(line) # :nodoc:
37
- file_tasks, args = line.split(':', 2)
38
+ file_tasks, args = line.split(":", 2)
38
39
  return if args.nil?
39
40
  dependents = args.split.map { |d| respace(d) }
40
41
  file_tasks.scan(/\S+/) do |file_task|
@@ -44,10 +45,10 @@ module Rake
44
45
  end
45
46
 
46
47
  def respace(str) # :nodoc:
47
- str.tr SPACE_MARK, ' '
48
+ str.tr SPACE_MARK, " "
48
49
  end
49
50
  end
50
51
 
51
52
  # Install the handler
52
- Rake.application.add_loader('mf', MakefileLoader.new)
53
+ Rake.application.add_loader("mf", MakefileLoader.new)
53
54
  end
@@ -1,3 +1,4 @@
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
@@ -5,9 +6,9 @@ module Rake
5
6
  #
6
7
  class MultiTask < Task
7
8
  private
9
+
8
10
  def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
9
11
  invoke_prerequisites_concurrently(task_args, invocation_chain)
10
12
  end
11
13
  end
12
-
13
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.
@@ -35,4 +36,3 @@ class Rake::NameSpace
35
36
  end
36
37
 
37
38
  end
38
-
@@ -1,8 +1,9 @@
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
 
4
- require 'rake'
5
- require 'rake/tasklib'
5
+ require "rake"
6
+ require "rake/tasklib"
6
7
 
7
8
  module Rake
8
9
 
@@ -63,6 +64,9 @@ module Rake
63
64
  # is false).
64
65
  attr_accessor :need_tar_bz2
65
66
 
67
+ # True if a xz'd tar file (tar.xz) should be produced (default is false)
68
+ attr_accessor :need_tar_xz
69
+
66
70
  # True if a zip file should be produced (default is false)
67
71
  attr_accessor :need_zip
68
72
 
@@ -75,6 +79,9 @@ module Rake
75
79
  # Zip command for zipped archives. The default is 'zip'.
76
80
  attr_accessor :zip_command
77
81
 
82
+ # True if parent directory should be omitted (default is false)
83
+ attr_accessor :without_parent_dir
84
+
78
85
  # Create a Package Task with the given name and version. Use +:noversion+
79
86
  # as the version to build a package without a version or to provide a
80
87
  # fully-versioned package name.
@@ -90,13 +97,15 @@ module Rake
90
97
  @name = name
91
98
  @version = version
92
99
  @package_files = Rake::FileList.new
93
- @package_dir = 'pkg'
100
+ @package_dir = "pkg"
94
101
  @need_tar = false
95
102
  @need_tar_gz = false
96
103
  @need_tar_bz2 = false
104
+ @need_tar_xz = false
97
105
  @need_zip = false
98
- @tar_command = 'tar'
99
- @zip_command = 'zip'
106
+ @tar_command = "tar"
107
+ @zip_command = "zip"
108
+ @without_parent_dir = false
100
109
  end
101
110
 
102
111
  # Create the tasks defined by this task library.
@@ -108,38 +117,37 @@ module Rake
108
117
  task :package
109
118
 
110
119
  desc "Force a rebuild of the package files"
111
- task :repackage => [:clobber_package, :package]
120
+ task repackage: [:clobber_package, :package]
112
121
 
113
122
  desc "Remove package products"
114
123
  task :clobber_package do
115
124
  rm_r package_dir rescue nil
116
125
  end
117
126
 
118
- task :clobber => [:clobber_package]
127
+ task clobber: [:clobber_package]
119
128
 
120
129
  [
121
130
  [need_tar, tgz_file, "z"],
122
131
  [need_tar_gz, tar_gz_file, "z"],
123
- [need_tar_bz2, tar_bz2_file, "j"]
124
- ].each do |(need, file, flag)|
132
+ [need_tar_bz2, tar_bz2_file, "j"],
133
+ [need_tar_xz, tar_xz_file, "J"]
134
+ ].each do |need, file, flag|
125
135
  if need
126
- task :package => ["#{package_dir}/#{file}"]
136
+ task package: ["#{package_dir}/#{file}"]
127
137
  file "#{package_dir}/#{file}" =>
128
138
  [package_dir_path] + package_files do
129
- chdir(package_dir) do
130
- sh @tar_command, "#{flag}cvf", file, package_name
131
- 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
132
141
  end
133
142
  end
134
143
  end
135
144
 
136
145
  if need_zip
137
- task :package => ["#{package_dir}/#{zip_file}"]
146
+ task package: ["#{package_dir}/#{zip_file}"]
138
147
  file "#{package_dir}/#{zip_file}" =>
139
148
  [package_dir_path] + package_files do
140
- chdir(package_dir) do
141
- sh @zip_command, "-r", zip_file, package_name
142
- 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
143
151
  end
144
152
  end
145
153
 
@@ -189,11 +197,26 @@ module Rake
189
197
  "#{package_name}.tar.bz2"
190
198
  end
191
199
 
200
+ # The package name with .tar.xz added
201
+
202
+ def tar_xz_file
203
+ "#{package_name}.tar.xz"
204
+ end
205
+
192
206
  # The package name with .zip added
193
207
 
194
208
  def zip_file
195
209
  "#{package_name}.zip"
196
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
197
220
  end
198
221
 
199
222
  end
data/lib/rake/phony.rb CHANGED
@@ -1,10 +1,11 @@
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.
4
5
  #
5
6
  # See FileTask#out_of_date? and Task#timestamp for more info.
6
7
 
7
- require 'rake'
8
+ require "rake"
8
9
 
9
10
  task :phony
10
11
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
 
3
4
  # Include PrivateReader to use +private_reader+.
data/lib/rake/promise.rb CHANGED
@@ -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
@@ -27,11 +28,11 @@ module Rake
27
28
  # synchronously. We will wait.
28
29
  def value
29
30
  unless complete?
30
- stat :sleeping_on, :item_id => object_id
31
+ stat :sleeping_on, item_id: object_id
31
32
  @mutex.synchronize do
32
- stat :has_lock_on, :item_id => object_id
33
+ stat :has_lock_on, item_id: object_id
33
34
  chore
34
- stat :releasing_lock_on, :item_id => object_id
35
+ stat :releasing_lock_on, item_id: object_id
35
36
  end
36
37
  end
37
38
  error? ? raise(@error) : @result
@@ -39,14 +40,14 @@ module Rake
39
40
 
40
41
  # If no one else is working this promise, go ahead and do the chore.
41
42
  def work
42
- stat :attempting_lock_on, :item_id => object_id
43
+ stat :attempting_lock_on, item_id: object_id
43
44
  if @mutex.try_lock
44
- stat :has_lock_on, :item_id => object_id
45
+ stat :has_lock_on, item_id: object_id
45
46
  chore
46
- stat :releasing_lock_on, :item_id => object_id
47
+ stat :releasing_lock_on, item_id: object_id
47
48
  @mutex.unlock
48
49
  else
49
- stat :bailed_on, :item_id => object_id
50
+ stat :bailed_on, item_id: object_id
50
51
  end
51
52
  end
52
53
 
@@ -55,27 +56,27 @@ module Rake
55
56
  # Perform the chore promised
56
57
  def chore
57
58
  if complete?
58
- stat :found_completed, :item_id => object_id
59
+ stat :found_completed, item_id: object_id
59
60
  return
60
61
  end
61
- stat :will_execute, :item_id => object_id
62
+ stat :will_execute, item_id: object_id
62
63
  begin
63
64
  @result = @block.call(*@args)
64
65
  rescue Exception => e
65
66
  @error = e
66
67
  end
67
- stat :did_execute, :item_id => object_id
68
+ stat :did_execute, item_id: object_id
68
69
  discard
69
70
  end
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,4 +1,5 @@
1
- require 'rake/application'
1
+ # frozen_string_literal: true
2
+ require "rake/application"
2
3
 
3
4
  module Rake
4
5
 
@@ -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,4 +1,6 @@
1
- require 'rake'
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/file_list"
2
4
 
3
5
  # Load the test files from the command line.
4
6
  argv = ARGV.select do |argument|
@@ -6,17 +8,20 @@ argv = ARGV.select do |argument|
6
8
  when /^-/ then
7
9
  argument
8
10
  when /\*/ then
9
- FileList[argument].to_a.each do |file|
11
+ Rake::FileList[argument].to_a.each do |file|
10
12
  require File.expand_path file
11
13
  end
12
14
 
13
15
  false
14
16
  else
15
- require File.expand_path argument
17
+ path = File.expand_path argument
18
+
19
+ abort "\nFile does not exist: #{path}\n\n" unless File.exist?(path)
20
+
21
+ require path
16
22
 
17
23
  false
18
24
  end
19
25
  end
20
26
 
21
27
  ARGV.replace argv
22
-
@@ -1,4 +1,4 @@
1
-
1
+ # frozen_string_literal: true
2
2
  module Rake
3
3
 
4
4
  # Error indicating a recursion overflow error in task selection.
@@ -13,7 +13,7 @@ module Rake
13
13
  end
14
14
 
15
15
  def message
16
- super + ": [" + @targets.reverse.join(' => ') + "]"
16
+ super + ": [" + @targets.reverse.join(" => ") + "]"
17
17
  end
18
18
  end
19
19
 
data/lib/rake/scope.rb CHANGED
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  module Rake
2
3
  class Scope < LinkedList # :nodoc: all
3
4
 
4
5
  # Path for the scope.
5
6
  def path
6
- map { |item| item.to_s }.reverse.join(":")
7
+ map(&:to_s).reverse.join(":")
7
8
  end
8
9
 
9
10
  # Path for the scope + the named path.
@@ -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