class KManager::Project

A project represents all the DSL and Data resources that are available, it keeps a track of the in memory state of the resources, are they loaded into memory or not.

Attributes

config[R]

Configuration for this project

name[R]

Project name

namespace[R]

Project namespace, aka namespace root

resources[R]

List of resources attached to this project

Public Class Methods

new(name, config = nil, **opts) click to toggle source
# File lib/k_manager/project.rb, line 21
def initialize(name, config = nil, **opts)
  raise KType::Error, 'Provide a project name' unless name.is_a?(String) || name.is_a?(Symbol)

  @name = name
  @config = config || KManager::Configuration::ProjectConfig.new
  @resources = []

  initialize_opts(opts)
end

Public Instance Methods

add_resource(resource) click to toggle source
# File lib/k_manager/project.rb, line 31
def add_resource(resource)
  # Need to check if this and resource.attach_project need to delegate to each other
  # Need to check that resources can't be added twice
  # Tests are required
  @resources << resource
end
infer_key() click to toggle source

Infer key is the project name stored in dash-case

# File lib/k_manager/project.rb, line 39
def infer_key
  Handlebars::Helpers::StringFormatting::Dasherize.new.parse(name.to_s.gsub('_', '-'))
end

Private Instance Methods

initialize_opts(opts) click to toggle source
# File lib/k_manager/project.rb, line 45
def initialize_opts(opts)
  # project name is often a good default for the namespace
  @namespace = opts[:namespace] || name
end