1module Rake
2
3  # The NameSpace class will lookup task names in the the scope
4  # defined by a +namespace+ command.
5  #
6  class NameSpace
7
8    # Create a namespace lookup object using the given task manager
9    # and the list of scopes.
10    def initialize(task_manager, scope_list)
11      @task_manager = task_manager
12      @scope = scope_list.dup
13    end
14
15    # Lookup a task named +name+ in the namespace.
16    def [](name)
17      @task_manager.lookup(name, @scope)
18    end
19
20    # Return the list of tasks defined in this and nested namespaces.
21    def tasks
22      @task_manager.tasks_in_scope(@scope)
23    end
24  end
25end
26