Class: Rdm::Gen::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rdm/gen/config.rb

Constant Summary collapse

TEMPLATE_NAME =
'configs'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_name, current_path, config_data) ⇒ Config

Returns a new instance of Config.



8
9
10
11
12
13
14
# File 'lib/rdm/gen/config.rb', line 8

def initialize(config_name, current_path, config_data)
  @current_path = current_path
  @config_name  = config_name
  @source       = get_source

  @config_locals  = Rdm::ConfigLocals.new(config_data)
end

Class Method Details

.generate(config_name:, current_path:, config_data: {}) ⇒ Object



4
5
6
# File 'lib/rdm/gen/config.rb', line 4

def self.generate(config_name:, current_path:, config_data: {})
  Rdm::Gen::Config.new(config_name, current_path, config_data = {}).generate
end

Instance Method Details

#generateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rdm/gen/config.rb', line 16

def generate
  @locals = {
    config_name:      @config_name,
    config_locals:    @config_locals,
    config_path:      config_path(@config_name),
    role_config_path: role_config_path(@config_name)
  }

  generated_files = Rdm::Handlers::TemplateHandler.generate(
    current_path:       @current_path,
    locals:             @locals,
    template_name:      TEMPLATE_NAME,
    local_path:         './'
  )

  Rdm::SourceModifier.add_config(@config_name, get_source.root_path)
  
  generated_files
end