The TaskManager module is a mixin for managing tasks.
- #
- A
- C
- D
- E
- F
- G
- I
- L
- M
- N
- R
- S
- T
[RW] | record_task_metadata | |
[RW] | last_comment | Track the last comment made in the Rakefile. |
[RW] | last_description | Track the last comment made in the Rakefile. |
Clear all tasks in this application.
Return the list of scope names currently active in the task manager.
# File ../ruby/lib/rake/task_manager.rb, line 23 def define_task(task_class, *args, &block) task_name, arg_names, deps = resolve_args(args) task_name = task_class.scope_name(@scope, task_name) deps = [deps] unless deps.respond_to?(:to_ary) deps = deps.collect {|d| d.to_s } task = intern(task_class, task_name) task.set_arg_names(arg_names) unless arg_names.empty? if Rake::TaskManager.record_task_metadata add_location(task) task.add_description(get_description(task)) end task.enhance(deps, &block) end
If a rule can be found that matches the task name, enhance the task with the prerequisites and actions from the rule. Set the source attribute of the task appropriately for the rule. Return the enhanced task or nil of no rule was found.
# File ../ruby/lib/rake/task_manager.rb, line 127 def enhance_with_matching_rule(task_name, level=0) fail Rake::RuleRecursionOverflowError, "Rule Recursion Too Deep" if level >= 16 @rules.each do |pattern, extensions, block| if pattern.match(task_name) task = attempt_rule(task_name, extensions, block, level) return task if task end end nil rescue Rake::RuleRecursionOverflowError => ex ex.add_target(task_name) fail ex end
Evaluate the block in a nested namespace named name
. Create
an anonymous namespace if name
is nil.
Lookup a task. Return an existing task if found, otherwise create a task of the current type.
Lookup a task, using scope and the scope hints in the task name. This method performs straight lookups without trying to synthesize file tasks or rules. Special scope names (e.g. '^') are recognized. If no scope argument is supplied, use the current scope. Return nil if the task cannot be found.
# File ../ruby/lib/rake/task_manager.rb, line 167 def lookup(task_name, initial_scope=nil) initial_scope ||= @scope task_name = task_name.to_s if task_name =~ /^rake:/ scopes = [] task_name = task_name.sub(/^rake:/, '') elsif task_name =~ /^(\^+)/ scopes = initial_scope[0, initial_scope.size - $1.size] task_name = task_name.sub(/^(\^+)/, '') else scopes = initial_scope end lookup_in_scope(task_name, scopes) end
Resolve the arguments for a task/rule. Returns a triplet of [task_name, arg_name_list, prerequisites].
List of all defined tasks in this application.
List of all the tasks defined in the given scope (and its sub-scopes).
Add a location to the locations field of the given task.
Attempt to create a rule given the list of prerequisites.
# File ../ruby/lib/rake/task_manager.rb, line 245 def attempt_rule(task_name, extensions, block, level) sources = make_sources(task_name, extensions) prereqs = sources.collect { |source| trace_rule level, "Attempting Rule #{task_name} => #{source}" if File.exist?(source) || Rake::Task.task_defined?(source) trace_rule level, "(#{task_name} => #{source} ... EXIST)" source elsif parent = enhance_with_matching_rule(source, level+1) trace_rule level, "(#{task_name} => #{source} ... ENHANCE)" parent.name else trace_rule level, "(#{task_name} => #{source} ... FAIL)" return nil end } task = FileTask.define_task({task_name => prereqs}, &block) task.sources = prereqs task end
Generate an anonymous namespace name.
Return the current description, clearing it in the process.
Lookup the task name
Make a list of sources from the list of file name extensions / translation procs.
# File ../ruby/lib/rake/task_manager.rb, line 267 def make_sources(task_name, extensions) result = extensions.collect { |ext| case ext when /%/ task_name.pathmap(ext) when %r{/} ext when /^\./ task_name.ext(ext) when String ext when Proc if ext.arity == 1 ext.call(task_name) else ext.call end else fail "Don't know how to handle rule dependent: #{ext.inspect}" end } result.flatten end
Resolve task arguments for a task or rule when there are no dependencies declared.
The patterns recognized by this argument resolving function are:
task :t
task :t, [:a]
task :t, :a (deprecated)