The TaskManager module is a mixin for managing tasks.

Methods
Attributes
[RW] last_comment Track the last comment made in the Rakefile.
Public Class methods
new()
      # File lib/rake.rb, line 1249
1249:     def initialize
1250:       super
1251:       @tasks = Hash.new
1252:       @rules = Array.new
1253:       @scope = Array.new
1254:       @last_comment = nil
1255:     end
Public Instance methods
[](task_name, scopes=nil)

Find a matching task for task_name.

      # File lib/rake.rb, line 1283
1283:     def [](task_name, scopes=nil)
1284:       task_name = task_name.to_s
1285:       self.lookup(task_name, scopes) or
1286:         enhance_with_matching_rule(task_name) or
1287:         synthesize_file_task(task_name) or
1288:         fail "Don't know how to build task '#{task_name}'"
1289:     end
clear()

Clear all tasks in this application.

      # File lib/rake.rb, line 1337
1337:     def clear
1338:       @tasks.clear
1339:       @rules.clear
1340:     end
create_rule(args, &block)
      # File lib/rake.rb, line 1257
1257:     def create_rule(args, &block)
1258:       pattern, deps = resolve_args(args)
1259:       pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
1260:       @rules << [pattern, deps, block]
1261:     end
current_scope()

Return the list of scope names currently active in the task manager.

      # File lib/rake.rb, line 1377
1377:     def current_scope
1378:       @scope.dup
1379:     end
define_task(task_class, args, &block)
      # File lib/rake.rb, line 1263
1263:     def define_task(task_class, args, &block)
1264:       task_name, deps = resolve_args(args)
1265:       task_name = task_class.scope_name(@scope, task_name)
1266:       deps = [deps] unless deps.respond_to?(:to_ary)
1267:       deps = deps.collect {|d| d.to_s }
1268:       task = intern(task_class, task_name)
1269:       task.application = self
1270:       task.add_comment(@last_comment)
1271:       @last_comment = nil
1272:       task.enhance(deps, &block)
1273:       task
1274:     end
enhance_with_matching_rule(task_name, level=0)

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 lib/rake.rb, line 1316
1316:     def enhance_with_matching_rule(task_name, level=0)
1317:       fail Rake::RuleRecursionOverflowError,
1318:         "Rule Recursion Too Deep" if level >= 16
1319:       @rules.each do |pattern, extensions, block|
1320:         if md = pattern.match(task_name)
1321:           task = attempt_rule(task_name, extensions, block, level)
1322:           return task if task
1323:         end
1324:       end
1325:       nil
1326:     rescue Rake::RuleRecursionOverflowError => ex
1327:       ex.add_target(task_name)
1328:       fail ex
1329:     end
in_namespace(name) {|ns| ...}

Evaluate the block in a nested namespace named name. Create an anonymous namespace if name is nil.

      # File lib/rake.rb, line 1383
1383:     def in_namespace(name)
1384:       name ||= generate_name
1385:       @scope.push(name)
1386:       ns = NameSpace.new(self, @scope)
1387:       yield(ns)
1388:       ns
1389:     ensure
1390:       @scope.pop
1391:     end
intern(task_class, task_name)

Lookup a task. Return an existing task if found, otherwise create a task of the current type.

      # File lib/rake.rb, line 1278
1278:     def intern(task_class, task_name)
1279:       @tasks[task_name.to_s] ||= task_class.new(task_name, self)
1280:     end
lookup(task_name, initial_scope=nil)

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 lib/rake.rb, line 1347
1347:     def lookup(task_name, initial_scope=nil)
1348:       initial_scope ||= @scope
1349:       task_name = task_name.to_s
1350:       if task_name =~ /^rake:/
1351:         scopes = []
1352:         task_name = task_name.sub(/^rake:/, '')
1353:       elsif task_name =~ /^(\^^+)/
1354:         scopes = initial_scope[0, initial_scope.size - $1.size]
1355:         task_name = task_name.sub(/^(\^^+)/, '')
1356:       else
1357:         scopes = initial_scope
1358:       end
1359:       lookup_in_scope(task_name, scopes)
1360:     end
resolve_args(args)

Resolve the arguments for a task/rule.

      # File lib/rake.rb, line 1297
1297:     def resolve_args(args)
1298:       case args
1299:       when Hash
1300:         fail "Too Many Task Names: #{args.keys.join(' ')}" if args.size > 1
1301:         fail "No Task Name Given" if args.size < 1
1302:         task_name = args.keys[0]
1303:         deps = args[task_name]
1304:         deps = [deps] if (String===deps) || (Regexp===deps) || (Proc===deps)
1305:       else
1306:         task_name = args
1307:         deps = []
1308:       end
1309:       [task_name, deps]
1310:     end
synthesize_file_task(task_name)
      # File lib/rake.rb, line 1291
1291:     def synthesize_file_task(task_name)
1292:       return nil unless File.exist?(task_name)
1293:       define_task(Rake::FileTask, task_name)
1294:     end
tasks()

List of all defined tasks in this application.

      # File lib/rake.rb, line 1332
1332:     def tasks
1333:       @tasks.values.sort_by { |t| t.name }
1334:     end