rake 0.9.2.2 → 13.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.rdoc +2403 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +64 -106
- data/doc/command_line_usage.rdoc +65 -21
- data/doc/glossary.rdoc +40 -49
- data/doc/jamis.rb +1 -0
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +127 -62
- data/{bin → exe}/rake +1 -7
- data/lib/rake/application.rb +507 -271
- data/lib/rake/backtrace.rb +24 -0
- data/lib/rake/clean.rb +54 -8
- data/lib/rake/cloneable.rb +11 -19
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +5 -0
- data/lib/rake/dsl_definition.rb +67 -48
- data/lib/rake/early_time.rb +5 -1
- data/lib/rake/ext/core.rb +5 -6
- data/lib/rake/ext/string.rb +61 -52
- data/lib/rake/file_creation_task.rb +4 -3
- data/lib/rake/file_list.rb +81 -49
- data/lib/rake/file_task.rb +15 -8
- data/lib/rake/file_utils.rb +63 -43
- data/lib/rake/file_utils_ext.rb +14 -25
- data/lib/rake/invocation_chain.rb +25 -19
- data/lib/rake/invocation_exception_mixin.rb +1 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +23 -9
- data/lib/rake/multi_task.rb +4 -6
- data/lib/rake/name_space.rb +36 -23
- data/lib/rake/packagetask.rb +71 -34
- 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 +8 -2
- data/lib/rake/rake_module.rb +41 -3
- data/lib/rake/rake_test_loader.rb +9 -4
- data/lib/rake/rule_recursion_overflow_error.rb +2 -2
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +186 -79
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +46 -15
- data/lib/rake/task_manager.rb +91 -67
- data/lib/rake/tasklib.rb +2 -12
- data/lib/rake/testtask.rb +61 -63
- data/lib/rake/thread_history_display.rb +49 -0
- data/lib/rake/thread_pool.rb +163 -0
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +5 -3
- data/lib/rake/win32.rb +14 -18
- data/lib/rake.rb +35 -33
- data/rake.gemspec +100 -0
- metadata +74 -176
- data/.gemtest +0 -0
- data/CHANGES +0 -522
- data/Rakefile +0 -369
- data/TODO +0 -20
- data/doc/rake.1.gz +0 -0
- data/doc/release_notes/rake-0.4.14.rdoc +0 -23
- data/doc/release_notes/rake-0.4.15.rdoc +0 -35
- data/doc/release_notes/rake-0.5.0.rdoc +0 -53
- data/doc/release_notes/rake-0.5.3.rdoc +0 -78
- data/doc/release_notes/rake-0.5.4.rdoc +0 -46
- data/doc/release_notes/rake-0.6.0.rdoc +0 -141
- data/doc/release_notes/rake-0.7.0.rdoc +0 -119
- data/doc/release_notes/rake-0.7.1.rdoc +0 -59
- data/doc/release_notes/rake-0.7.2.rdoc +0 -121
- data/doc/release_notes/rake-0.7.3.rdoc +0 -47
- data/doc/release_notes/rake-0.8.0.rdoc +0 -114
- data/doc/release_notes/rake-0.8.2.rdoc +0 -165
- data/doc/release_notes/rake-0.8.3.rdoc +0 -112
- data/doc/release_notes/rake-0.8.4.rdoc +0 -147
- data/doc/release_notes/rake-0.8.5.rdoc +0 -53
- data/doc/release_notes/rake-0.8.6.rdoc +0 -55
- data/doc/release_notes/rake-0.8.7.rdoc +0 -55
- data/doc/release_notes/rake-0.9.0.rdoc +0 -112
- data/doc/release_notes/rake-0.9.1.rdoc +0 -52
- data/doc/release_notes/rake-0.9.2.rdoc +0 -49
- data/install.rb +0 -90
- data/lib/rake/alt_system.rb +0 -109
- data/lib/rake/classic_namespace.rb +0 -11
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -150
- data/lib/rake/contrib/publisher.rb +0 -73
- data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
- data/lib/rake/contrib/sshpublisher.rb +0 -50
- data/lib/rake/contrib/sys.rb +0 -191
- data/lib/rake/ext/module.rb +0 -39
- data/lib/rake/ext/time.rb +0 -14
- data/lib/rake/gempackagetask.rb +0 -15
- data/lib/rake/pathmap.rb +0 -1
- data/lib/rake/rdoctask.rb +0 -234
- data/lib/rake/ruby182_test_unit_fix.rb +0 -25
- data/lib/rake/runtest.rb +0 -21
- data/test/file_creation.rb +0 -34
- data/test/helper.rb +0 -492
- data/test/test_rake.rb +0 -40
- data/test/test_rake_application.rb +0 -489
- data/test/test_rake_application_options.rb +0 -335
- data/test/test_rake_clean.rb +0 -14
- data/test/test_rake_definitions.rb +0 -80
- data/test/test_rake_directory_task.rb +0 -46
- data/test/test_rake_dsl.rb +0 -77
- data/test/test_rake_early_time.rb +0 -31
- data/test/test_rake_extension.rb +0 -59
- data/test/test_rake_file_creation_task.rb +0 -56
- data/test/test_rake_file_list.rb +0 -628
- data/test/test_rake_file_list_path_map.rb +0 -8
- data/test/test_rake_file_task.rb +0 -102
- data/test/test_rake_file_utils.rb +0 -305
- data/test/test_rake_ftp_file.rb +0 -59
- data/test/test_rake_functional.rb +0 -450
- data/test/test_rake_invocation_chain.rb +0 -52
- data/test/test_rake_makefile_loader.rb +0 -44
- data/test/test_rake_multi_task.rb +0 -51
- data/test/test_rake_name_space.rb +0 -43
- data/test/test_rake_package_task.rb +0 -79
- data/test/test_rake_path_map.rb +0 -157
- data/test/test_rake_path_map_explode.rb +0 -34
- data/test/test_rake_path_map_partial.rb +0 -18
- data/test/test_rake_pseudo_status.rb +0 -21
- data/test/test_rake_rake_test_loader.rb +0 -21
- data/test/test_rake_rdoc_task.rb +0 -83
- data/test/test_rake_require.rb +0 -40
- data/test/test_rake_rules.rb +0 -327
- data/test/test_rake_task.rb +0 -267
- data/test/test_rake_task_argument_parsing.rb +0 -103
- data/test/test_rake_task_arguments.rb +0 -88
- data/test/test_rake_task_lib.rb +0 -9
- data/test/test_rake_task_manager.rb +0 -157
- data/test/test_rake_task_manager_argument_resolution.rb +0 -36
- data/test/test_rake_task_with_arguments.rb +0 -173
- data/test/test_rake_test_task.rb +0 -120
- data/test/test_rake_top_level_functions.rb +0 -111
- data/test/test_rake_win32.rb +0 -72
- data/test/test_sys.rb +0 -20
data/lib/rake/task.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake/invocation_exception_mixin"
|
2
3
|
|
3
4
|
module Rake
|
4
5
|
|
5
|
-
|
6
|
+
##
|
6
7
|
# A Task is the basic unit of work in a Rakefile. Tasks have associated
|
7
8
|
# actions (possibly more than one) and a list of prerequisites. When
|
8
9
|
# invoked, a task will first ensure that all of its prerequisites have an
|
@@ -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
|
@@ -21,13 +26,6 @@ module Rake
|
|
21
26
|
# Application owning this task.
|
22
27
|
attr_accessor :application
|
23
28
|
|
24
|
-
# Comment for this task. Restricted to a single line of no more than 50
|
25
|
-
# characters.
|
26
|
-
attr_reader :comment
|
27
|
-
|
28
|
-
# Full text of the (possibly multi-line) comment.
|
29
|
-
attr_reader :full_comment
|
30
|
-
|
31
29
|
# Array of nested namespaces names used for task lookup by this task.
|
32
30
|
attr_reader :scope
|
33
31
|
|
@@ -36,50 +34,81 @@ module Rake
|
|
36
34
|
# location option set).
|
37
35
|
attr_reader :locations
|
38
36
|
|
37
|
+
# Has this task already been invoked? Already invoked tasks
|
38
|
+
# will be skipped unless you reenable them.
|
39
|
+
attr_reader :already_invoked
|
40
|
+
|
39
41
|
# Return task name
|
40
42
|
def to_s
|
41
43
|
name
|
42
44
|
end
|
43
45
|
|
44
|
-
def inspect
|
46
|
+
def inspect # :nodoc:
|
45
47
|
"<#{self.class} #{name} => [#{prerequisites.join(', ')}]>"
|
46
48
|
end
|
47
49
|
|
48
50
|
# List of sources for task.
|
49
51
|
attr_writer :sources
|
50
52
|
def sources
|
51
|
-
@sources
|
53
|
+
if defined?(@sources)
|
54
|
+
@sources
|
55
|
+
else
|
56
|
+
prerequisites
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
# List of prerequisite tasks
|
55
61
|
def prerequisite_tasks
|
56
|
-
prerequisites.
|
62
|
+
(prerequisites + order_only_prerequisites).map { |pre| lookup_prerequisite(pre) }
|
57
63
|
end
|
58
64
|
|
59
|
-
def lookup_prerequisite(prerequisite_name)
|
60
|
-
application[prerequisite_name, @scope]
|
65
|
+
def lookup_prerequisite(prerequisite_name) # :nodoc:
|
66
|
+
scoped_prerequisite_task = application[prerequisite_name, @scope]
|
67
|
+
if scoped_prerequisite_task == self
|
68
|
+
unscoped_prerequisite_task = application[prerequisite_name]
|
69
|
+
end
|
70
|
+
unscoped_prerequisite_task || scoped_prerequisite_task
|
61
71
|
end
|
62
72
|
private :lookup_prerequisite
|
63
73
|
|
74
|
+
# List of all unique prerequisite tasks including prerequisite tasks'
|
75
|
+
# prerequisites.
|
76
|
+
# Includes self when cyclic dependencies are found.
|
77
|
+
def all_prerequisite_tasks
|
78
|
+
seen = {}
|
79
|
+
collect_prerequisites(seen)
|
80
|
+
seen.values
|
81
|
+
end
|
82
|
+
|
83
|
+
def collect_prerequisites(seen) # :nodoc:
|
84
|
+
prerequisite_tasks.each do |pre|
|
85
|
+
next if seen[pre.name]
|
86
|
+
seen[pre.name] = pre
|
87
|
+
pre.collect_prerequisites(seen)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
protected :collect_prerequisites
|
91
|
+
|
64
92
|
# First source from a rule (nil if no sources)
|
65
93
|
def source
|
66
|
-
|
94
|
+
sources.first
|
67
95
|
end
|
68
96
|
|
69
97
|
# Create a task named +task_name+ with no actions or prerequisites. Use
|
70
98
|
# +enhance+ to add actions and prerequisites.
|
71
99
|
def initialize(task_name, app)
|
72
|
-
@name
|
73
|
-
@prerequisites
|
74
|
-
@actions
|
100
|
+
@name = task_name.to_s
|
101
|
+
@prerequisites = []
|
102
|
+
@actions = []
|
75
103
|
@already_invoked = false
|
76
|
-
@
|
77
|
-
@
|
78
|
-
@
|
79
|
-
@
|
80
|
-
@
|
81
|
-
@
|
82
|
-
@
|
104
|
+
@comments = []
|
105
|
+
@lock = Monitor.new
|
106
|
+
@application = app
|
107
|
+
@scope = app.current_scope
|
108
|
+
@arg_names = nil
|
109
|
+
@locations = []
|
110
|
+
@invocation_exception = nil
|
111
|
+
@order_only_prerequisites = []
|
83
112
|
end
|
84
113
|
|
85
114
|
# Enhance a task with prerequisites or actions. Returns self.
|
@@ -105,7 +134,7 @@ module Rake
|
|
105
134
|
|
106
135
|
# Argument description (nil if none).
|
107
136
|
def arg_description # :nodoc:
|
108
|
-
@arg_names ? "[#{
|
137
|
+
@arg_names ? "[#{arg_names.join(',')}]" : nil
|
109
138
|
end
|
110
139
|
|
111
140
|
# Name of arguments for this task.
|
@@ -117,12 +146,15 @@ module Rake
|
|
117
146
|
# is invoked again.
|
118
147
|
def reenable
|
119
148
|
@already_invoked = false
|
149
|
+
@invocation_exception = nil
|
120
150
|
end
|
121
151
|
|
122
|
-
# Clear the existing prerequisites and
|
152
|
+
# Clear the existing prerequisites, actions, comments, and arguments of a rake task.
|
123
153
|
def clear
|
124
154
|
clear_prerequisites
|
125
155
|
clear_actions
|
156
|
+
clear_comments
|
157
|
+
clear_args
|
126
158
|
self
|
127
159
|
end
|
128
160
|
|
@@ -138,6 +170,18 @@ module Rake
|
|
138
170
|
self
|
139
171
|
end
|
140
172
|
|
173
|
+
# Clear the existing comments on a rake task.
|
174
|
+
def clear_comments
|
175
|
+
@comments = []
|
176
|
+
self
|
177
|
+
end
|
178
|
+
|
179
|
+
# Clear the existing arguments on a rake task.
|
180
|
+
def clear_args
|
181
|
+
@arg_names = nil
|
182
|
+
self
|
183
|
+
end
|
184
|
+
|
141
185
|
# Invoke the task if it is needed. Prerequisites are invoked first.
|
142
186
|
def invoke(*args)
|
143
187
|
task_args = TaskArguments.new(arg_names, args)
|
@@ -146,35 +190,71 @@ module Rake
|
|
146
190
|
|
147
191
|
# Same as invoke, but explicitly pass a call chain to detect
|
148
192
|
# circular dependencies.
|
149
|
-
|
150
|
-
|
193
|
+
#
|
194
|
+
# If multiple tasks depend on this
|
195
|
+
# one in parallel, they will all fail if the first execution of
|
196
|
+
# this task fails.
|
197
|
+
def invoke_with_call_chain(task_args, invocation_chain)
|
198
|
+
new_chain = Rake::InvocationChain.append(self, invocation_chain)
|
151
199
|
@lock.synchronize do
|
152
|
-
|
153
|
-
|
200
|
+
begin
|
201
|
+
if application.options.trace
|
202
|
+
application.trace "** Invoke #{name} #{format_trace_flags}"
|
203
|
+
end
|
204
|
+
|
205
|
+
if @already_invoked
|
206
|
+
if @invocation_exception
|
207
|
+
if application.options.trace
|
208
|
+
application.trace "** Previous invocation of #{name} failed #{format_trace_flags}"
|
209
|
+
end
|
210
|
+
raise @invocation_exception
|
211
|
+
else
|
212
|
+
return
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
@already_invoked = true
|
217
|
+
|
218
|
+
invoke_prerequisites(task_args, new_chain)
|
219
|
+
execute(task_args) if needed?
|
220
|
+
rescue Exception => ex
|
221
|
+
add_chain_to(ex, new_chain)
|
222
|
+
@invocation_exception = ex
|
223
|
+
raise ex
|
154
224
|
end
|
155
|
-
return if @already_invoked
|
156
|
-
@already_invoked = true
|
157
|
-
invoke_prerequisites(task_args, new_chain)
|
158
|
-
execute(task_args) if needed?
|
159
225
|
end
|
160
|
-
rescue Exception => ex
|
161
|
-
add_chain_to(ex, new_chain)
|
162
|
-
raise ex
|
163
226
|
end
|
164
227
|
protected :invoke_with_call_chain
|
165
228
|
|
166
|
-
def add_chain_to(exception, new_chain)
|
167
|
-
exception.extend(InvocationExceptionMixin) unless
|
229
|
+
def add_chain_to(exception, new_chain) # :nodoc:
|
230
|
+
exception.extend(InvocationExceptionMixin) unless
|
231
|
+
exception.respond_to?(:chain)
|
168
232
|
exception.chain = new_chain if exception.chain.nil?
|
169
233
|
end
|
170
234
|
private :add_chain_to
|
171
235
|
|
172
236
|
# Invoke all the prerequisites of a task.
|
173
237
|
def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
238
|
+
if application.options.always_multitask
|
239
|
+
invoke_prerequisites_concurrently(task_args, invocation_chain)
|
240
|
+
else
|
241
|
+
prerequisite_tasks.each { |p|
|
242
|
+
prereq_args = task_args.new_scope(p.arg_names)
|
243
|
+
p.invoke_with_call_chain(prereq_args, invocation_chain)
|
244
|
+
}
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
# Invoke all the prerequisites of a task in parallel.
|
249
|
+
def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc:
|
250
|
+
futures = prerequisite_tasks.map do |p|
|
251
|
+
prereq_args = task_args.new_scope(p.arg_names)
|
252
|
+
application.thread_pool.future(p) do |r|
|
253
|
+
r.invoke_with_call_chain(prereq_args, invocation_chain)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
# Iterate in reverse to improve performance related to thread waiting and switching
|
257
|
+
futures.reverse_each(&:value)
|
178
258
|
end
|
179
259
|
|
180
260
|
# Format the trace flags for display.
|
@@ -190,20 +270,15 @@ module Rake
|
|
190
270
|
def execute(args=nil)
|
191
271
|
args ||= EMPTY_TASK_ARGS
|
192
272
|
if application.options.dryrun
|
193
|
-
|
273
|
+
application.trace "** Execute (dry run) #{name}"
|
194
274
|
return
|
195
275
|
end
|
196
|
-
if application.options.trace
|
197
|
-
$stderr.puts "** Execute #{name}"
|
198
|
-
end
|
276
|
+
application.trace "** Execute #{name}" if application.options.trace
|
199
277
|
application.enhance_with_matching_rule(name) if @actions.empty?
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
else
|
205
|
-
act.call(self, args)
|
206
|
-
end
|
278
|
+
if opts = Hash.try_convert(args) and !opts.empty?
|
279
|
+
@actions.each { |act| act.call(self, args, **opts)}
|
280
|
+
else
|
281
|
+
@actions.each { |act| act.call(self, args)}
|
207
282
|
end
|
208
283
|
end
|
209
284
|
|
@@ -215,65 +290,97 @@ module Rake
|
|
215
290
|
# Timestamp for this task. Basic tasks return the current time for their
|
216
291
|
# time stamp. Other tasks can be more sophisticated.
|
217
292
|
def timestamp
|
218
|
-
|
293
|
+
Time.now
|
219
294
|
end
|
220
295
|
|
221
296
|
# Add a description to the task. The description can consist of an option
|
222
297
|
# argument list (enclosed brackets) and an optional comment.
|
223
298
|
def add_description(description)
|
224
|
-
return
|
299
|
+
return unless description
|
225
300
|
comment = description.strip
|
226
|
-
add_comment(comment) if comment && !
|
301
|
+
add_comment(comment) if comment && !comment.empty?
|
227
302
|
end
|
228
303
|
|
229
|
-
|
230
|
-
|
231
|
-
add_description(description)
|
304
|
+
def comment=(comment) # :nodoc:
|
305
|
+
add_comment(comment)
|
232
306
|
end
|
233
307
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
308
|
+
def add_comment(comment) # :nodoc:
|
309
|
+
return if comment.nil?
|
310
|
+
@comments << comment unless @comments.include?(comment)
|
311
|
+
end
|
312
|
+
private :add_comment
|
313
|
+
|
314
|
+
# Full collection of comments. Multiple comments are separated by
|
315
|
+
# newlines.
|
316
|
+
def full_comment
|
317
|
+
transform_comments("\n")
|
318
|
+
end
|
319
|
+
|
320
|
+
# First line (or sentence) of all comments. Multiple comments are
|
321
|
+
# separated by a "/".
|
322
|
+
def comment
|
323
|
+
transform_comments(" / ") { |c| first_sentence(c) }
|
324
|
+
end
|
325
|
+
|
326
|
+
# Transform the list of comments as specified by the block and
|
327
|
+
# join with the separator.
|
328
|
+
def transform_comments(separator, &block)
|
329
|
+
if @comments.empty?
|
330
|
+
nil
|
245
331
|
else
|
246
|
-
|
332
|
+
block ||= lambda { |c| c }
|
333
|
+
@comments.map(&block).join(separator)
|
247
334
|
end
|
248
335
|
end
|
249
|
-
private :
|
336
|
+
private :transform_comments
|
337
|
+
|
338
|
+
# Get the first sentence in a string. The sentence is terminated
|
339
|
+
# by the first period, exclamation mark, or the end of the line.
|
340
|
+
# Decimal points do not count as periods.
|
341
|
+
def first_sentence(string)
|
342
|
+
string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first
|
343
|
+
end
|
344
|
+
private :first_sentence
|
250
345
|
|
251
346
|
# Set the names of the arguments for this task. +args+ should be
|
252
347
|
# an array of symbols, one for each argument name.
|
253
348
|
def set_arg_names(args)
|
254
|
-
@arg_names = args.map
|
349
|
+
@arg_names = args.map(&:to_sym)
|
255
350
|
end
|
256
351
|
|
257
352
|
# Return a string describing the internal state of a task. Useful for
|
258
353
|
# debugging.
|
259
354
|
def investigation
|
260
|
-
result = "------------------------------\n"
|
355
|
+
result = "------------------------------\n".dup
|
261
356
|
result << "Investigating #{name}\n"
|
262
357
|
result << "class: #{self.class}\n"
|
263
358
|
result << "task needed: #{needed?}\n"
|
264
359
|
result << "timestamp: #{timestamp}\n"
|
265
360
|
result << "pre-requisites: \n"
|
266
361
|
prereqs = prerequisite_tasks
|
267
|
-
prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
|
362
|
+
prereqs.sort! { |a, b| a.timestamp <=> b.timestamp }
|
268
363
|
prereqs.each do |p|
|
269
364
|
result << "--#{p.name} (#{p.timestamp})\n"
|
270
365
|
end
|
271
|
-
latest_prereq = prerequisite_tasks.
|
366
|
+
latest_prereq = prerequisite_tasks.map(&:timestamp).max
|
272
367
|
result << "latest-prerequisite time: #{latest_prereq}\n"
|
273
368
|
result << "................................\n\n"
|
274
369
|
return result
|
275
370
|
end
|
276
371
|
|
372
|
+
# Format dependencies parameter to pass to task.
|
373
|
+
def self.format_deps(deps)
|
374
|
+
deps = [deps] unless deps.respond_to?(:to_ary)
|
375
|
+
deps.map { |d| Rake.from_pathname(d).to_s }
|
376
|
+
end
|
377
|
+
|
378
|
+
# Add order only dependencies.
|
379
|
+
def |(deps)
|
380
|
+
@order_only_prerequisites |= Task.format_deps(deps) - @prerequisites
|
381
|
+
self
|
382
|
+
end
|
383
|
+
|
277
384
|
# ----------------------------------------------------------------
|
278
385
|
# Rake Module Methods
|
279
386
|
#
|
@@ -319,7 +426,7 @@ module Rake
|
|
319
426
|
# this kind of task. Generic tasks will accept the scope as
|
320
427
|
# part of the name.
|
321
428
|
def scope_name(scope, task_name)
|
322
|
-
|
429
|
+
scope.path_with_task_name(task_name)
|
323
430
|
end
|
324
431
|
|
325
432
|
end # class << Rake::Task
|
data/lib/rake/task_arguments.rb
CHANGED
@@ -1,30 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
3
|
|
3
|
-
|
4
|
+
##
|
4
5
|
# TaskArguments manage the arguments passed to a task.
|
5
6
|
#
|
6
7
|
class TaskArguments
|
7
8
|
include Enumerable
|
8
9
|
|
10
|
+
# Argument names
|
9
11
|
attr_reader :names
|
10
12
|
|
11
|
-
# Create a TaskArgument object with a list of
|
12
|
-
#
|
13
|
-
# :values). :parent is the parent argument object.
|
13
|
+
# Create a TaskArgument object with a list of argument +names+ and a set
|
14
|
+
# of associated +values+. +parent+ is the parent argument object.
|
14
15
|
def initialize(names, values, parent=nil)
|
15
16
|
@names = names
|
16
17
|
@parent = parent
|
17
18
|
@hash = {}
|
19
|
+
@values = values
|
18
20
|
names.each_with_index { |name, i|
|
19
|
-
|
21
|
+
next if values[i].nil? || values[i] == ""
|
22
|
+
@hash[name.to_sym] = values[i]
|
20
23
|
}
|
21
24
|
end
|
22
25
|
|
26
|
+
# Retrieve the complete array of sequential values
|
27
|
+
def to_a
|
28
|
+
@values.dup
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieve the list of values not associated with named arguments
|
32
|
+
def extras
|
33
|
+
@values[@names.length..-1] || []
|
34
|
+
end
|
35
|
+
|
23
36
|
# Create a new argument scope using the prerequisite argument
|
24
37
|
# names.
|
25
38
|
def new_scope(names)
|
26
|
-
values = names.
|
27
|
-
self.class.new(names, values, self)
|
39
|
+
values = names.map { |n| self[n] }
|
40
|
+
self.class.new(names, values + extras, self)
|
28
41
|
end
|
29
42
|
|
30
43
|
# Find an argument value by name or index.
|
@@ -39,33 +52,51 @@ module Rake
|
|
39
52
|
@hash = defaults.merge(@hash)
|
40
53
|
end
|
41
54
|
|
55
|
+
# Enumerates the arguments and their values
|
42
56
|
def each(&block)
|
43
57
|
@hash.each(&block)
|
44
58
|
end
|
45
59
|
|
60
|
+
# Extracts the argument values at +keys+
|
46
61
|
def values_at(*keys)
|
47
62
|
keys.map { |k| lookup(k) }
|
48
63
|
end
|
49
64
|
|
50
|
-
|
65
|
+
# Returns the value of the given argument via method_missing
|
66
|
+
def method_missing(sym, *args)
|
51
67
|
lookup(sym.to_sym)
|
52
68
|
end
|
53
69
|
|
70
|
+
# Returns a Hash of arguments and their values
|
54
71
|
def to_hash
|
55
|
-
@hash
|
72
|
+
@hash.dup
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_s # :nodoc:
|
76
|
+
inspect
|
77
|
+
end
|
78
|
+
|
79
|
+
def inspect # :nodoc:
|
80
|
+
inspection = @hash.map do |k,v|
|
81
|
+
"#{k.to_s}: #{v.to_s}"
|
82
|
+
end.join(", ")
|
83
|
+
|
84
|
+
"#<#{self.class} #{inspection}>"
|
56
85
|
end
|
57
86
|
|
58
|
-
|
59
|
-
|
87
|
+
# Returns true if +key+ is one of the arguments
|
88
|
+
def has_key?(key)
|
89
|
+
@hash.has_key?(key)
|
60
90
|
end
|
91
|
+
alias key? has_key?
|
61
92
|
|
62
|
-
def
|
63
|
-
|
93
|
+
def fetch(*args, &block)
|
94
|
+
@hash.fetch(*args, &block)
|
64
95
|
end
|
65
96
|
|
66
97
|
protected
|
67
98
|
|
68
|
-
def lookup(name)
|
99
|
+
def lookup(name) # :nodoc:
|
69
100
|
if @hash.has_key?(name)
|
70
101
|
@hash[name]
|
71
102
|
elsif @parent
|
@@ -74,5 +105,5 @@ module Rake
|
|
74
105
|
end
|
75
106
|
end
|
76
107
|
|
77
|
-
EMPTY_TASK_ARGS = TaskArguments.new([], [])
|
108
|
+
EMPTY_TASK_ARGS = TaskArguments.new([], []) # :nodoc:
|
78
109
|
end
|