rake 0.4.11 → 13.4.2
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.
- checksums.yaml +7 -0
- data/History.rdoc +2454 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +155 -0
- data/doc/command_line_usage.rdoc +171 -0
- data/doc/glossary.rdoc +40 -49
- data/doc/jamis.rb +135 -107
- data/doc/proto_rake.rdoc +22 -22
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +428 -27
- data/doc/rational.rdoc +6 -6
- data/exe/rake +27 -0
- data/lib/rake/application.rb +847 -0
- data/lib/rake/backtrace.rb +25 -0
- data/lib/rake/clean.rb +57 -10
- data/lib/rake/cloneable.rb +17 -0
- data/lib/rake/cpu_counter.rb +122 -0
- data/lib/rake/default_loader.rb +15 -0
- data/lib/rake/dsl_definition.rb +196 -0
- data/lib/rake/early_time.rb +22 -0
- data/lib/rake/ext/core.rb +26 -0
- data/lib/rake/ext/string.rb +176 -0
- data/lib/rake/file_creation_task.rb +25 -0
- data/lib/rake/file_list.rb +435 -0
- data/lib/rake/file_task.rb +58 -0
- data/lib/rake/file_utils.rb +137 -0
- data/lib/rake/file_utils_ext.rb +135 -0
- data/lib/rake/invocation_chain.rb +57 -0
- data/lib/rake/invocation_exception_mixin.rb +17 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +54 -0
- data/lib/rake/multi_task.rb +14 -0
- data/lib/rake/name_space.rb +38 -0
- data/lib/rake/options.rb +31 -0
- data/lib/rake/packagetask.rb +124 -54
- data/lib/rake/phony.rb +16 -0
- data/lib/rake/private_reader.rb +21 -0
- data/lib/rake/promise.rb +100 -0
- data/lib/rake/pseudo_status.rb +30 -0
- data/lib/rake/rake_module.rb +67 -0
- data/lib/rake/rake_test_loader.rb +27 -0
- data/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +434 -0
- data/lib/rake/task_argument_error.rb +8 -0
- data/lib/rake/task_arguments.rb +113 -0
- data/lib/rake/task_manager.rb +333 -0
- data/lib/rake/tasklib.rb +4 -16
- data/lib/rake/testtask.rb +110 -36
- data/lib/rake/thread_history_display.rb +49 -0
- data/lib/rake/thread_pool.rb +157 -0
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +10 -0
- data/lib/rake/win32.rb +17 -0
- data/lib/rake.rb +64 -992
- data/rake.gemspec +102 -0
- metadata +117 -89
- data/CHANGES +0 -153
- data/README +0 -209
- data/Rakefile +0 -215
- data/TODO +0 -19
- data/bin/rake +0 -8
- data/install.rb +0 -88
- data/lib/rake/contrib/compositepublisher.rb +0 -24
- data/lib/rake/contrib/ftptools.rb +0 -139
- data/lib/rake/contrib/publisher.rb +0 -75
- data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
- data/lib/rake/contrib/sshpublisher.rb +0 -47
- data/lib/rake/contrib/sys.rb +0 -207
- data/lib/rake/gempackagetask.rb +0 -98
- data/lib/rake/rdoctask.rb +0 -128
- data/lib/rake/runtest.rb +0 -23
- data/test/contrib/testsys.rb +0 -47
- data/test/data/rbext/rakefile.rb +0 -3
- data/test/filecreation.rb +0 -26
- data/test/functional.rb +0 -82
- data/test/shellcommand.rb +0 -3
- data/test/testclean.rb +0 -13
- data/test/testfilelist.rb +0 -255
- data/test/testfileutils.rb +0 -83
- data/test/testftp.rb +0 -55
- data/test/testpackagetask.rb +0 -81
- data/test/testtasks.rb +0 -371
- data/test/testtesttask.rb +0 -71
data/lib/rake/packagetask.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# Define a package task libarary to aid in the definition of
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Define a package task library to aid in the definition of
|
|
4
3
|
# redistributable package files.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
require_relative "../rake"
|
|
6
|
+
require_relative "tasklib"
|
|
8
7
|
|
|
9
8
|
module Rake
|
|
10
9
|
|
|
@@ -13,26 +12,32 @@ module Rake
|
|
|
13
12
|
#
|
|
14
13
|
# The PackageTask will create the following targets:
|
|
15
14
|
#
|
|
16
|
-
#
|
|
15
|
+
# +:package+ ::
|
|
17
16
|
# Create all the requested package files.
|
|
18
17
|
#
|
|
19
|
-
#
|
|
18
|
+
# +:clobber_package+ ::
|
|
20
19
|
# Delete all the package files. This target is automatically
|
|
21
20
|
# added to the main clobber target.
|
|
22
21
|
#
|
|
23
|
-
#
|
|
22
|
+
# +:repackage+ ::
|
|
24
23
|
# Rebuild the package files from scratch, even if they are not out
|
|
25
24
|
# of date.
|
|
26
25
|
#
|
|
27
|
-
#
|
|
28
|
-
# Create a gzipped tar package (if <em>need_tar</em> is true).
|
|
26
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</tt> ::
|
|
27
|
+
# Create a gzipped tar package (if <em>need_tar</em> is true).
|
|
28
|
+
#
|
|
29
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</tt> ::
|
|
30
|
+
# Create a gzipped tar package (if <em>need_tar_gz</em> is true).
|
|
29
31
|
#
|
|
30
|
-
#
|
|
32
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</tt> ::
|
|
33
|
+
# Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
|
|
34
|
+
#
|
|
35
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</tt> ::
|
|
31
36
|
# Create a zip package archive (if <em>need_zip</em> is true).
|
|
32
37
|
#
|
|
33
38
|
# Example:
|
|
34
39
|
#
|
|
35
|
-
# PackageTask.new("rake", "1.2.3") do |p|
|
|
40
|
+
# Rake::PackageTask.new("rake", "1.2.3") do |p|
|
|
36
41
|
# p.need_tar = true
|
|
37
42
|
# p.package_files.include("lib/**/*.rb")
|
|
38
43
|
# end
|
|
@@ -47,16 +52,40 @@ module Rake
|
|
|
47
52
|
# Directory used to store the package files (default is 'pkg').
|
|
48
53
|
attr_accessor :package_dir
|
|
49
54
|
|
|
50
|
-
# True if a gzipped tar file should be produced (default is
|
|
55
|
+
# True if a gzipped tar file (tgz) should be produced (default is
|
|
56
|
+
# false).
|
|
51
57
|
attr_accessor :need_tar
|
|
52
58
|
|
|
59
|
+
# True if a gzipped tar file (tar.gz) should be produced (default
|
|
60
|
+
# is false).
|
|
61
|
+
attr_accessor :need_tar_gz
|
|
62
|
+
|
|
63
|
+
# True if a bzip2'd tar file (tar.bz2) should be produced (default
|
|
64
|
+
# is false).
|
|
65
|
+
attr_accessor :need_tar_bz2
|
|
66
|
+
|
|
67
|
+
# True if a xz'd tar file (tar.xz) should be produced (default is false)
|
|
68
|
+
attr_accessor :need_tar_xz
|
|
69
|
+
|
|
53
70
|
# True if a zip file should be produced (default is false)
|
|
54
71
|
attr_accessor :need_zip
|
|
55
72
|
|
|
56
73
|
# List of files to be included in the package.
|
|
57
74
|
attr_accessor :package_files
|
|
58
75
|
|
|
59
|
-
#
|
|
76
|
+
# Tar command for gzipped or bzip2ed archives. The default is 'tar'.
|
|
77
|
+
attr_accessor :tar_command
|
|
78
|
+
|
|
79
|
+
# Zip command for zipped archives. The default is 'zip'.
|
|
80
|
+
attr_accessor :zip_command
|
|
81
|
+
|
|
82
|
+
# True if parent directory should be omitted (default is false)
|
|
83
|
+
attr_accessor :without_parent_dir
|
|
84
|
+
|
|
85
|
+
# Create a Package Task with the given name and version. Use +:noversion+
|
|
86
|
+
# as the version to build a package without a version or to provide a
|
|
87
|
+
# fully-versioned package name.
|
|
88
|
+
|
|
60
89
|
def initialize(name=nil, version=nil)
|
|
61
90
|
init(name, version)
|
|
62
91
|
yield self if block_given?
|
|
@@ -68,9 +97,15 @@ module Rake
|
|
|
68
97
|
@name = name
|
|
69
98
|
@version = version
|
|
70
99
|
@package_files = Rake::FileList.new
|
|
71
|
-
@package_dir =
|
|
100
|
+
@package_dir = "pkg"
|
|
72
101
|
@need_tar = false
|
|
102
|
+
@need_tar_gz = false
|
|
103
|
+
@need_tar_bz2 = false
|
|
104
|
+
@need_tar_xz = false
|
|
73
105
|
@need_zip = false
|
|
106
|
+
@tar_command = "tar"
|
|
107
|
+
@zip_command = "zip"
|
|
108
|
+
@without_parent_dir = false
|
|
74
109
|
end
|
|
75
110
|
|
|
76
111
|
# Create the tasks defined by this task library.
|
|
@@ -80,73 +115,108 @@ module Rake
|
|
|
80
115
|
|
|
81
116
|
desc "Build all the packages"
|
|
82
117
|
task :package
|
|
83
|
-
|
|
118
|
+
|
|
84
119
|
desc "Force a rebuild of the package files"
|
|
85
|
-
task :
|
|
86
|
-
|
|
87
|
-
desc "Remove package products"
|
|
120
|
+
task repackage: [:clobber_package, :package]
|
|
121
|
+
|
|
122
|
+
desc "Remove package products"
|
|
88
123
|
task :clobber_package do
|
|
89
|
-
|
|
124
|
+
rm_r package_dir rescue nil
|
|
90
125
|
end
|
|
91
126
|
|
|
92
|
-
task :
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
127
|
+
task clobber: [:clobber_package]
|
|
128
|
+
|
|
129
|
+
[
|
|
130
|
+
[need_tar, tgz_file, "z"],
|
|
131
|
+
[need_tar_gz, tar_gz_file, "z"],
|
|
132
|
+
[need_tar_bz2, tar_bz2_file, "j"],
|
|
133
|
+
[need_tar_xz, tar_xz_file, "J"]
|
|
134
|
+
].each do |need, file, flag|
|
|
135
|
+
if need
|
|
136
|
+
task package: ["#{package_dir}/#{file}"]
|
|
137
|
+
file "#{package_dir}/#{file}" =>
|
|
138
|
+
[package_dir_path] + package_files do
|
|
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
|
|
141
|
+
end
|
|
142
|
+
end
|
|
101
143
|
end
|
|
102
144
|
|
|
103
145
|
if need_zip
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
146
|
+
task package: ["#{package_dir}/#{zip_file}"]
|
|
147
|
+
file "#{package_dir}/#{zip_file}" =>
|
|
148
|
+
[package_dir_path] + package_files do
|
|
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
|
|
151
|
+
end
|
|
110
152
|
end
|
|
111
153
|
|
|
112
|
-
directory
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
safe_ln(fn, f)
|
|
125
|
-
end
|
|
126
|
-
end
|
|
154
|
+
directory package_dir_path => @package_files do
|
|
155
|
+
@package_files.each do |fn|
|
|
156
|
+
f = File.join(package_dir_path, fn)
|
|
157
|
+
fdir = File.dirname(f)
|
|
158
|
+
mkdir_p(fdir) unless File.exist?(fdir)
|
|
159
|
+
if File.directory?(fn)
|
|
160
|
+
mkdir_p(f)
|
|
161
|
+
else
|
|
162
|
+
rm_f f
|
|
163
|
+
safe_ln(fn, f)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
127
166
|
end
|
|
128
167
|
self
|
|
129
168
|
end
|
|
130
169
|
|
|
131
|
-
|
|
170
|
+
# The name of this package
|
|
132
171
|
|
|
133
172
|
def package_name
|
|
134
173
|
@version ? "#{@name}-#{@version}" : @name
|
|
135
174
|
end
|
|
136
|
-
|
|
175
|
+
|
|
176
|
+
# The directory this package will be built in
|
|
177
|
+
|
|
137
178
|
def package_dir_path
|
|
138
179
|
"#{package_dir}/#{package_name}"
|
|
139
180
|
end
|
|
140
181
|
|
|
182
|
+
# The package name with .tgz added
|
|
183
|
+
|
|
141
184
|
def tgz_file
|
|
142
185
|
"#{package_name}.tgz"
|
|
143
186
|
end
|
|
144
187
|
|
|
188
|
+
# The package name with .tar.gz added
|
|
189
|
+
|
|
190
|
+
def tar_gz_file
|
|
191
|
+
"#{package_name}.tar.gz"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# The package name with .tar.bz2 added
|
|
195
|
+
|
|
196
|
+
def tar_bz2_file
|
|
197
|
+
"#{package_name}.tar.bz2"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# The package name with .tar.xz added
|
|
201
|
+
|
|
202
|
+
def tar_xz_file
|
|
203
|
+
"#{package_name}.tar.xz"
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# The package name with .zip added
|
|
207
|
+
|
|
145
208
|
def zip_file
|
|
146
209
|
"#{package_name}.zip"
|
|
147
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
|
|
148
220
|
end
|
|
149
221
|
|
|
150
222
|
end
|
|
151
|
-
|
|
152
|
-
|
data/lib/rake/phony.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Defines a :phony task that you can use as a dependency. This allows
|
|
3
|
+
# file-based tasks to use non-file-based tasks as prerequisites
|
|
4
|
+
# without forcing them to rebuild.
|
|
5
|
+
#
|
|
6
|
+
# See FileTask#out_of_date? and Task#timestamp for more info.
|
|
7
|
+
|
|
8
|
+
require_relative "../rake"
|
|
9
|
+
|
|
10
|
+
task :phony
|
|
11
|
+
|
|
12
|
+
Rake::Task[:phony].tap do |task|
|
|
13
|
+
def task.timestamp # :nodoc:
|
|
14
|
+
Time.at 0
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Rake
|
|
3
|
+
|
|
4
|
+
# Include PrivateReader to use +private_reader+.
|
|
5
|
+
module PrivateReader # :nodoc: all
|
|
6
|
+
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.extend(ClassMethods)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module ClassMethods
|
|
12
|
+
|
|
13
|
+
# Declare a list of private accessors
|
|
14
|
+
def private_reader(*names)
|
|
15
|
+
attr_reader(*names)
|
|
16
|
+
private(*names)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/rake/promise.rb
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Rake
|
|
3
|
+
|
|
4
|
+
# A Promise object represents a promise to do work (a chore) in the
|
|
5
|
+
# future. The promise is created with a block and a list of
|
|
6
|
+
# arguments for the block. Calling value will return the value of
|
|
7
|
+
# the promised chore.
|
|
8
|
+
#
|
|
9
|
+
# Used by ThreadPool.
|
|
10
|
+
#
|
|
11
|
+
class Promise # :nodoc: all
|
|
12
|
+
NOT_SET = Object.new.freeze # :nodoc:
|
|
13
|
+
|
|
14
|
+
attr_accessor :recorder
|
|
15
|
+
|
|
16
|
+
# Create a promise to do the chore specified by the block.
|
|
17
|
+
def initialize(args, &block)
|
|
18
|
+
@mutex = Mutex.new
|
|
19
|
+
@result = NOT_SET
|
|
20
|
+
@error = NOT_SET
|
|
21
|
+
@args = args
|
|
22
|
+
@block = block
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Return the value of this promise.
|
|
26
|
+
#
|
|
27
|
+
# If the promised chore is not yet complete, then do the work
|
|
28
|
+
# synchronously. We will wait.
|
|
29
|
+
def value
|
|
30
|
+
unless complete?
|
|
31
|
+
stat :sleeping_on, item_id: object_id
|
|
32
|
+
@mutex.synchronize do
|
|
33
|
+
stat :has_lock_on, item_id: object_id
|
|
34
|
+
chore
|
|
35
|
+
stat :releasing_lock_on, item_id: object_id
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
error? ? raise(@error) : @result
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# If no one else is working this promise, go ahead and do the chore.
|
|
42
|
+
def work
|
|
43
|
+
stat :attempting_lock_on, item_id: object_id
|
|
44
|
+
if @mutex.try_lock
|
|
45
|
+
stat :has_lock_on, item_id: object_id
|
|
46
|
+
chore
|
|
47
|
+
stat :releasing_lock_on, item_id: object_id
|
|
48
|
+
@mutex.unlock
|
|
49
|
+
else
|
|
50
|
+
stat :bailed_on, item_id: object_id
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
# Perform the chore promised
|
|
57
|
+
def chore
|
|
58
|
+
if complete?
|
|
59
|
+
stat :found_completed, item_id: object_id
|
|
60
|
+
return
|
|
61
|
+
end
|
|
62
|
+
stat :will_execute, item_id: object_id
|
|
63
|
+
begin
|
|
64
|
+
@result = @block.call(*@args)
|
|
65
|
+
rescue Exception => e
|
|
66
|
+
@error = e
|
|
67
|
+
end
|
|
68
|
+
stat :did_execute, item_id: object_id
|
|
69
|
+
discard
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Do we have a result for the promise
|
|
73
|
+
def result?
|
|
74
|
+
!@result.equal?(NOT_SET)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Did the promise throw an error
|
|
78
|
+
def error?
|
|
79
|
+
!@error.equal?(NOT_SET)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Are we done with the promise
|
|
83
|
+
def complete?
|
|
84
|
+
result? || error?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# free up these items for the GC
|
|
88
|
+
def discard
|
|
89
|
+
@args = nil
|
|
90
|
+
@block = nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Record execution statistics if there is a recorder
|
|
94
|
+
def stat(*args)
|
|
95
|
+
@recorder.call(*args) if @recorder
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Rake
|
|
3
|
+
|
|
4
|
+
##
|
|
5
|
+
# Exit status class for times the system just gives us a nil.
|
|
6
|
+
class PseudoStatus # :nodoc: all
|
|
7
|
+
attr_reader :exitstatus
|
|
8
|
+
|
|
9
|
+
def initialize(code=0)
|
|
10
|
+
@exitstatus = code
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_i
|
|
14
|
+
@exitstatus << 8
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def >>(n)
|
|
18
|
+
to_i >> n
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def stopped?
|
|
22
|
+
false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def exited?
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "rake/application"
|
|
3
|
+
|
|
4
|
+
module Rake
|
|
5
|
+
|
|
6
|
+
class << self
|
|
7
|
+
# Current Rake Application
|
|
8
|
+
def application
|
|
9
|
+
@application ||= Rake::Application.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Set the current Rake application object.
|
|
13
|
+
def application=(app)
|
|
14
|
+
@application = app
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def suggested_thread_count # :nodoc:
|
|
18
|
+
@cpu_count ||= Rake::CpuCounter.count
|
|
19
|
+
@cpu_count + 4
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Return the original directory where the Rake application was started.
|
|
23
|
+
def original_dir
|
|
24
|
+
application.original_dir
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Load a rakefile.
|
|
28
|
+
def load_rakefile(path)
|
|
29
|
+
load(path)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Add files to the rakelib list
|
|
33
|
+
def add_rakelib(*files)
|
|
34
|
+
application.options.rakelib ||= []
|
|
35
|
+
application.options.rakelib.concat(files)
|
|
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
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "file_list"
|
|
4
|
+
|
|
5
|
+
# Load the test files from the command line.
|
|
6
|
+
argv = ARGV.select do |argument|
|
|
7
|
+
case argument
|
|
8
|
+
when /^-/ then
|
|
9
|
+
argument
|
|
10
|
+
when /\*/ then
|
|
11
|
+
Rake::FileList[argument].to_a.each do |file|
|
|
12
|
+
require File.expand_path file
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
false
|
|
16
|
+
else
|
|
17
|
+
path = File.expand_path argument
|
|
18
|
+
|
|
19
|
+
abort "\nFile does not exist: #{path}\n\n" unless File.exist?(path)
|
|
20
|
+
|
|
21
|
+
require path
|
|
22
|
+
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
ARGV.replace argv
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Rake
|
|
3
|
+
|
|
4
|
+
# Error indicating a recursion overflow error in task selection.
|
|
5
|
+
class RuleRecursionOverflowError < StandardError
|
|
6
|
+
def initialize(*args)
|
|
7
|
+
super
|
|
8
|
+
@targets = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def add_target(target)
|
|
12
|
+
@targets << target
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def message
|
|
16
|
+
super + ": [" + @targets.reverse.join(" => ") + "]"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
data/lib/rake/scope.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Rake
|
|
3
|
+
class Scope < LinkedList # :nodoc: all
|
|
4
|
+
|
|
5
|
+
# Path for the scope.
|
|
6
|
+
def path
|
|
7
|
+
map(&:to_s).reverse.join(":")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Path for the scope + the named path.
|
|
11
|
+
def path_with_task_name(task_name)
|
|
12
|
+
"#{path}:#{task_name}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Trim +n+ innermost scope levels from the scope. In no case will
|
|
16
|
+
# this trim beyond the toplevel scope.
|
|
17
|
+
def trim(n)
|
|
18
|
+
result = self
|
|
19
|
+
while n > 0 && !result.empty?
|
|
20
|
+
result = result.tail
|
|
21
|
+
n -= 1
|
|
22
|
+
end
|
|
23
|
+
result
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Scope lists always end with an EmptyScope object. See Null
|
|
27
|
+
# Object Pattern)
|
|
28
|
+
class EmptyScope < EmptyLinkedList
|
|
29
|
+
@parent = Scope
|
|
30
|
+
|
|
31
|
+
def path
|
|
32
|
+
""
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def path_with_task_name(task_name)
|
|
36
|
+
task_name
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Singleton null object for an empty scope.
|
|
41
|
+
EMPTY = EmptyScope.new
|
|
42
|
+
end
|
|
43
|
+
end
|