Class: MTBuild::BuildRegistry
- Inherits:
-
Object
- Object
- MTBuild::BuildRegistry
- Defined in:
- lib/mtbuild/build_registry.rb
Overview
This class holds the mtbuild workspace hierarchy
Class Attribute Summary collapse
-
.active_workspace ⇒ Object
readonly
The top-level workspace.
-
.projects ⇒ Object
readonly
The map of registered projects.
-
.top_workspace ⇒ Object
readonly
The top-level workspace.
-
.workspaces ⇒ Object
readonly
The map of registered workspaces.
Class Method Summary collapse
-
.enter_project(project_name, project) ⇒ Object
Track the beginning of a new project’s creation.
-
.enter_workspace(workspace_name, workspace) ⇒ Object
Track the beginning of a new workspace’s creation.
-
.exit_project ⇒ Object
Track the completion of a new project’s creation.
-
.exit_workspace ⇒ Object
Track the completion of a new workspace’s creation.
-
.expect_project ⇒ Object
Register that we next expect to encounter a project, not a workspace.
-
.expect_workspace ⇒ Object
Register that we next expect to encounter a workspace, not a project.
-
.found_project(project_name) ⇒ Object
Register that we encountered a project and verify that it’s allowed.
-
.found_workspace(workspace_name) ⇒ Object
Register that we encountered a workspace and verify that it’s allowed.
-
.hierarchical_name(name) ⇒ Object
Get a workspace/project name that reflects the workspace/project hierarchy.
-
.reenter_workspace(workspace) ⇒ Object
Track the re-entry into a parent workspace after importing a child workspace.
Class Attribute Details
.active_workspace ⇒ Object (readonly)
The top-level workspace
25 26 27 |
# File 'lib/mtbuild/build_registry.rb', line 25 def active_workspace @active_workspace end |
.projects ⇒ Object (readonly)
The map of registered projects
19 20 21 |
# File 'lib/mtbuild/build_registry.rb', line 19 def projects @projects end |
.top_workspace ⇒ Object (readonly)
The top-level workspace
22 23 24 |
# File 'lib/mtbuild/build_registry.rb', line 22 def top_workspace @top_workspace end |
.workspaces ⇒ Object (readonly)
The map of registered workspaces
16 17 18 |
# File 'lib/mtbuild/build_registry.rb', line 16 def workspaces @workspaces end |
Class Method Details
.enter_project(project_name, project) ⇒ Object
Track the beginning of a new project’s creation
51 52 53 54 55 56 57 |
# 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) ⇒ Object
Track the beginning of a new workspace’s creation
28 29 30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
Track the completion of a new project’s creation
60 61 |
# File 'lib/mtbuild/build_registry.rb', line 60 def exit_project end |
.exit_workspace ⇒ Object
Track the completion of a new workspace’s creation
47 48 |
# File 'lib/mtbuild/build_registry.rb', line 47 def exit_workspace end |
.expect_project ⇒ Object
Register that we next expect to encounter a project, not a workspace
70 71 72 73 |
# File 'lib/mtbuild/build_registry.rb', line 70 def expect_project # We expect an explicitly-added project. @expecting=:added_project end |
.expect_workspace ⇒ Object
Register that we next expect to encounter a workspace, not a project
64 65 66 67 |
# 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) ⇒ Object
Register that we encountered a project and verify that it’s allowed
86 87 88 89 90 91 92 |
# 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) ⇒ Object
Register that we encountered a workspace and verify that it’s allowed
76 77 78 79 80 81 82 83 |
# 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) ⇒ Object
Get a workspace/project name that reflects the workspace/project hierarchy
95 96 97 98 |
# File 'lib/mtbuild/build_registry.rb', line 95 def hierarchical_name(name) return name if @active_workspace.nil? "#{@active_workspace.workspace_name}:#{name}" end |