Module: ConfigHelper

Defined in:
lib/helpers/config_helper.rb

Class Method Summary collapse

Class Method Details

.get_namespace_and_projectObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/helpers/config_helper.rb', line 8

def self.get_namespace_and_project
  namespace_path = '../.byld/config.yml'
  project_path = '.byld/config.yml'

  namespace_config = Config.load(namespace_path) if File.exist?(namespace_path)
  project_config = Config.load(project_path) if File.exist?(project_path)

  if namespace_config.nil? or project_config.nil?
    puts "\n🚫 Config is missing! Note: This command is valid only within block or gate directory \n\n"
    exit
  end

  namespace_id = namespace_config['namespace']['id']
  project_id = project_config['project']['id']

  [namespace_id, project_id]
end

.get_namespace_idObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/helpers/config_helper.rb', line 26

def self.get_namespace_id
  config_path = '.byld/config.yml'
  config = Config.load(config_path) if File.exist?(config_path)

  if config.nil?
    puts "\n🚫 Config is missing! Note: This command is valid only within block or gate or project directory \n\n"
    exit
  end
  
  if config['namespace'].present?
    config['namespace']['id']
  elsif config['project'].present?
    config['project']['namespaceId']
  end
end

.save_config(key, dir, config) ⇒ Object



3
4
5
6
# File 'lib/helpers/config_helper.rb', line 3

def self.save_config(key, dir, config)
  block_config = Config.load("#{dir}/.byld/config.yml")
  block_config.merge!(key => config)
end