Method: Ruber::World::ProjectFactory#project

Defined in:
lib/ruber/world/project_factory.rb

#project(file, name = nil) ⇒ Project

Retrieves the project associated with a given project file

If a project associated with the project file file already exists, that project is returned. Otherwise, a new project is created. In this case, the #project_created signal is emitted

Parameters:

  • file (String)

    the path of the project file (it doesn’t need to exist)

  • name (String, nil) (defaults to: nil)

    the name of the project. If the project file already exists, then this should be nil. If the project file doesn’t exist, this should not be nil

Returns:

  • (Project)

    a project associated with file

Raises:

  • (MismatchingNameError)

    if name is specified, a project associated with file already exists but name and the name of the existing project are different



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/ruber/world/project_factory.rb', line 98

def project file, name = nil
  prj = @projects[file]
  if prj
    if name and prj.project_name != name
      raise MismatchingNameError.new file, name, prj.project_name
    end
    prj
  else
    prj = Project.new file, name
    connect prj, SIGNAL('closing(QObject*)'), self, SLOT('project_closing(QObject*)')
    @projects[prj.project_file] = prj
    emit project_created prj
    prj
  end
end