Class: Manifold::API::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/manifold/api/project.rb

Overview

Projects API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, logger: Logger.new($stdout), directory: Pathname.pwd.join(name)) ⇒ Project

Returns a new instance of Project.



9
10
11
12
13
# File 'lib/manifold/api/project.rb', line 9

def initialize(name, logger: Logger.new($stdout), directory: Pathname.pwd.join(name))
  @name = name
  @logger = logger
  @directory = Pathname(directory)
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



7
8
9
# File 'lib/manifold/api/project.rb', line 7

def directory
  @directory
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/manifold/api/project.rb', line 7

def logger
  @logger
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/manifold/api/project.rb', line 7

def name
  @name
end

Class Method Details

.create(name, directory: Pathname.pwd.join(name)) ⇒ Object



15
16
17
18
19
# File 'lib/manifold/api/project.rb', line 15

def self.create(name, directory: Pathname.pwd.join(name))
  new(name, directory:).tap do |project|
    [project.workspaces_directory, project.vectors_directory].each(&:mkpath)
  end
end

Instance Method Details

#generateObject



25
26
27
# File 'lib/manifold/api/project.rb', line 25

def generate
  workspaces.each(&:generate)
end

#vectors_directoryObject



33
34
35
# File 'lib/manifold/api/project.rb', line 33

def vectors_directory
  directory.join("vectors")
end

#workspacesObject



21
22
23
# File 'lib/manifold/api/project.rb', line 21

def workspaces
  @workspaces ||= workspace_directories.map { |dir| Workspace.from_directory(dir, logger:) }
end

#workspaces_directoryObject



29
30
31
# File 'lib/manifold/api/project.rb', line 29

def workspaces_directory
  directory.join("workspaces")
end