class MTBuild::BuildRegistry

This class holds the mtbuild workspace hierarchy

Attributes

active_workspace[R]

The top-level workspace

projects[R]

The map of registered projects

top_workspace[R]

The top-level workspace

workspaces[R]

The map of registered workspaces

Public Class Methods

enter_project(project_name, project) click to toggle source

Track the beginning of a new project's creation

# File lib/mtbuild/build_registry.rb, line 51
def enter_project(project_name, project)
  project_name = self.hierarchical_name(project_name)
  self.found_project(project_name)
  fail "A project named #{project_name} was already added." if @projects.has_key?(project_name)
  @projects[project_name] = project
  return project_name, @active_workspace
end
enter_workspace(workspace_name, workspace) click to toggle source

Track the beginning of a new workspace's creation

# File lib/mtbuild/build_registry.rb, line 28
def enter_workspace(workspace_name, workspace)
  workspace_name = self.hierarchical_name(workspace_name)
  self.found_workspace(workspace_name)
  fail "A workspace named #{workspace_name} was already added." if @workspaces.has_key?(workspace_name)
  @workspaces[workspace_name] = workspace
  @top_workspace = workspace if @top_workspace.nil?
  parent = @active_workspace
  @active_workspace = workspace
  return workspace_name, parent
end
exit_project() click to toggle source

Track the completion of a new project's creation

# File lib/mtbuild/build_registry.rb, line 60
def exit_project
end
exit_workspace() click to toggle source

Track the completion of a new workspace's creation

# File lib/mtbuild/build_registry.rb, line 47
def exit_workspace
end
expect_project() click to toggle source

Register that we next expect to encounter a project, not a workspace

# File lib/mtbuild/build_registry.rb, line 70
def expect_project
  # We expect an explicitly-added project.
  @expecting=:added_project
end
expect_workspace() click to toggle source

Register that we next expect to encounter a workspace, not a project

# File lib/mtbuild/build_registry.rb, line 64
def expect_workspace
  # We expect an explicitly-added workspace.
  @expecting=:added_workspace
end
found_project(project_name) click to toggle source

Register that we encountered a project and verify that it's allowed

# File lib/mtbuild/build_registry.rb, line 86
def found_project(project_name)
  unless [:project_or_workspace, :project, :added_project].include? @expecting
    fail "#{project_name} was added with add_workspace(), but it contains a project. Use add_project() if you want to include it." if @expecting==:added_workspace
  end
  # We expect nothing but top-level projects now.
  @expecting=:project
end
found_workspace(workspace_name) click to toggle source

Register that we encountered a workspace and verify that it's allowed

# File lib/mtbuild/build_registry.rb, line 76
def found_workspace(workspace_name)
  unless [:project_or_workspace, :added_workspace].include? @expecting
    fail "#{workspace_name} was added with add_project(), but it contains a workspace. Use add_workspace() if you want to include it." if @expecting==:added_project
    fail "Encountered workspace #{workspace_name} declared after a project or another workspace in the same file. This isn't allowed."
  end
  # We expect nothing but top-level projects now.
  @expecting=:project
end
hierarchical_name(name) click to toggle source

Get a workspace/project name that reflects the workspace/project hierarchy

# File lib/mtbuild/build_registry.rb, line 95
def hierarchical_name(name)
  return name if @active_workspace.nil?
  "#{@active_workspace.workspace_name}:#{name}"
end
reenter_workspace(workspace) click to toggle source

Track the re-entry into a parent workspace after importing a child workspace.

# File lib/mtbuild/build_registry.rb, line 40
def reenter_workspace(workspace)
  last_workspace = @active_workspace
  @active_workspace = workspace
  last_workspace
end