[RW] |
last_description |
Track the last comment made in the Rakefile.
|
[RW] |
record_task_metadata |
|
9: def initialize
10: super
11: @tasks = Hash.new
12: @rules = Array.new
13: @scope = Array.new
14: @last_description = nil
15: end
Find a matching task for task_name.
44: def [](task_name, scopes=nil)
45: task_name = task_name.to_s
46: self.lookup(task_name, scopes) or
47: enhance_with_matching_rule(task_name) or
48: synthesize_file_task(task_name) or
49: fail "Don't know how to build task '#{task_name}'"
50: end
Clear all tasks in this application.
153: def clear
154: @tasks.clear
155: @rules.clear
156: end
17: def create_rule(*args, &block)
18: pattern, arg_names, deps = resolve_args(args)
19: pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
20: @rules << [pattern, deps, block]
21: end
Return the list of scope names currently active in the task manager.
193: def current_scope
194: @scope.dup
195: end
23: def define_task(task_class, *args, &block)
24: task_name, arg_names, deps = resolve_args(args)
25: task_name = task_class.scope_name(@scope, task_name)
26: deps = [deps] unless deps.respond_to?(:to_ary)
27: deps = deps.collect {|d| d.to_s }
28: task = intern(task_class, task_name)
29: task.set_arg_names(arg_names) unless arg_names.empty?
30: if Rake::TaskManager.record_task_metadata
31: add_location(task)
32: task.add_description(get_description(task))
33: end
34: task.enhance(deps, &block)
35: 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.
123: def enhance_with_matching_rule(task_name, level=0)
124: fail Rake::RuleRecursionOverflowError,
125: "Rule Recursion Too Deep" if level >= 16
126: @rules.each do |pattern, extensions, block|
127: if md = pattern.match(task_name)
128: task = attempt_rule(task_name, extensions, block, level)
129: return task if task
130: end
131: end
132: nil
133: rescue Rake::RuleRecursionOverflowError => ex
134: ex.add_target(task_name)
135: fail ex
136: end
Evaluate the block in a nested namespace named name. Create an
anonymous namespace if name is nil.
199: def in_namespace(name)
200: name ||= generate_name
201: @scope.push(name)
202: ns = NameSpace.new(self, @scope)
203: yield(ns)
204: ns
205: ensure
206: @scope.pop
207: end
Lookup a task. Return an existing task if found, otherwise create a task of
the current type.
39: def intern(task_class, task_name)
40: @tasks[task_name.to_s] ||= task_class.new(task_name, self)
41: end
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.
163: def lookup(task_name, initial_scope=nil)
164: initial_scope ||= @scope
165: task_name = task_name.to_s
166: if task_name =~ /^rake:/
167: scopes = []
168: task_name = task_name.sub(/^rake:/, '')
169: elsif task_name =~ /^(\^+)/
170: scopes = initial_scope[0, initial_scope.size - $1.size]
171: task_name = task_name.sub(/^(\^+)/, '')
172: else
173: scopes = initial_scope
174: end
175: lookup_in_scope(task_name, scopes)
176: end
Resolve the arguments for a task/rule. Returns a triplet of [task_name,
arg_name_list, prerequisites].
59: def resolve_args(args)
60: if args.last.is_a?(Hash)
61: deps = args.pop
62: resolve_args_with_dependencies(args, deps)
63: else
64: resolve_args_without_dependencies(args)
65: end
66: end
52: def synthesize_file_task(task_name)
53: return nil unless File.exist?(task_name)
54: define_task(Rake::FileTask, task_name)
55: end
List of all defined tasks in this
application.
139: def tasks
140: @tasks.values.sort_by { |t| t.name }
141: end
List of all the tasks defined in the
given scope (and its sub-scopes).
145: def tasks_in_scope(scope)
146: prefix = scope.join(":")
147: tasks.select { |t|
148: /^#{prefix}:/ =~ t.name
149: }
150: end