Sha256: 2cd1f3da851fabbc1f16950f1c5a6c5e01fbaa76f18f0b0cc2891eab7cee4262

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Manifold
  module API
    # Projects API
    class Project
      attr_reader :name, :logger, :directory

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

      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

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

      def generate
        workspaces.each(&:generate)
      end

      def workspaces_directory
        directory.join("workspaces")
      end

      def vectors_directory
        directory.join("vectors")
      end

      private

      def workspace_directories
        workspaces_directory.children.select(&:directory?)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
manifold-cli-0.0.8 lib/manifold/api/project.rb