Class: Manifold::API::Workspace
- Inherits:
-
Object
- Object
- Manifold::API::Workspace
- Defined in:
- lib/manifold/api/workspace.rb
Overview
Encapsulates a single manifold.
Constant Summary collapse
- DEFAULT_TEMPLATE_PATH =
File.( "../templates/workspace_template.yml", __dir__ ).freeze
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
Class Method Summary collapse
Instance Method Summary collapse
- #add ⇒ Object
- #generate ⇒ Object
-
#initialize(name, template_path: DEFAULT_TEMPLATE_PATH, logger: Logger.new($stdout)) ⇒ Workspace
constructor
A new instance of Workspace.
- #manifold_exists? ⇒ Boolean
- #manifold_file ⇒ Object
- #manifold_path ⇒ Object
- #routines_directory ⇒ Object
- #tables_directory ⇒ Object
Constructor Details
#initialize(name, template_path: DEFAULT_TEMPLATE_PATH, logger: Logger.new($stdout)) ⇒ Workspace
Returns a new instance of Workspace.
13 14 15 16 17 18 |
# File 'lib/manifold/api/workspace.rb', line 13 def initialize(name, template_path: DEFAULT_TEMPLATE_PATH, logger: Logger.new($stdout)) @name = name @template_path = template_path @logger = logger @vector_service = Services::VectorService.new(logger) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/manifold/api/workspace.rb', line 7 def logger @logger end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/manifold/api/workspace.rb', line 7 def name @name end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
7 8 9 |
# File 'lib/manifold/api/workspace.rb', line 7 def template_path @template_path end |
Class Method Details
.from_directory(directory, logger: Logger.new($stdout)) ⇒ Object
20 21 22 |
# File 'lib/manifold/api/workspace.rb', line 20 def self.from_directory(directory, logger: Logger.new($stdout)) new(directory.basename.to_s, logger:) end |
Instance Method Details
#add ⇒ Object
24 25 26 27 |
# File 'lib/manifold/api/workspace.rb', line 24 def add [tables_directory, routines_directory].each(&:mkpath) FileUtils.cp(template_path, manifold_path) end |
#generate ⇒ Object
29 30 31 32 33 34 |
# File 'lib/manifold/api/workspace.rb', line 29 def generate return unless manifold_exists? && any_vectors? generate_dimensions logger.info("Generated BigQuery dimensions table schema for workspace '#{name}'.") end |
#manifold_exists? ⇒ Boolean
50 51 52 |
# File 'lib/manifold/api/workspace.rb', line 50 def manifold_exists? manifold_path.file? end |
#manifold_file ⇒ Object
44 45 46 47 48 |
# File 'lib/manifold/api/workspace.rb', line 44 def manifold_file return nil unless manifold_exists? File.new(manifold_path) end |
#manifold_path ⇒ Object
54 55 56 |
# File 'lib/manifold/api/workspace.rb', line 54 def manifold_path directory.join("manifold.yml") end |
#routines_directory ⇒ Object
40 41 42 |
# File 'lib/manifold/api/workspace.rb', line 40 def routines_directory directory.join("routines") end |
#tables_directory ⇒ Object
36 37 38 |
# File 'lib/manifold/api/workspace.rb', line 36 def tables_directory directory.join("tables") end |