Class: Terradactyl::ConfigProject

Inherits:
ConfigApplication show all
Includes:
Singleton
Defined in:
lib/terradactyl/config.rb

Constant Summary collapse

CONFIG_PROJECT_FILE =
'terradactyl.yaml'

Constants inherited from ConfigApplication

Terradactyl::ConfigApplication::CONFIG_DEFAULTS

Instance Attribute Summary

Attributes inherited from ConfigApplication

#terradactyl

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ConfigApplication

#initialize, #reload, #to_h

Constructor Details

This class inherits a constructor from Terradactyl::ConfigApplication

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Terradactyl::ConfigApplication

Class Method Details

.instanceObject



119
120
121
# File 'lib/terradactyl/config.rb', line 119

def self.instance
  @instance ||= new
end

Instance Method Details

#config_fileObject



133
134
135
# File 'lib/terradactyl/config.rb', line 133

def config_file
  @config_file = CONFIG_PROJECT_FILE
end

#load_overlay(overload) ⇒ Object



125
126
127
128
129
130
131
# File 'lib/terradactyl/config.rb', line 125

def load_overlay(overload)
  config_file_path = overload ? "./#{overload}/#{config_file}" : config_file

  YAML.load_file(config_file_path)
rescue Errno::ENOENT => e
  abort "FATAL: Could not load project file: `#{config_file}`, #{e.message}"
end

#merge_overlay(overlay_path) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/terradactyl/config.rb', line 137

def merge_overlay(overlay_path)
  config_file_path = overlay_path ? "./#{overlay_path}/#{config_file}" : config_file

  config_to_merge = YAML.load_file(config_file_path)

  # set base_folder name if it's '.'
  if config_to_merge['terradactyl']['base_folder'] == '.'
    config_to_merge['terradactyl']['base_folder'] = overlay_path
  end

  load_config(overlay_override: config_to_merge)
rescue Errno::ENOENT => e
  abort "FATAL: Could not load project file: `#{config_file}`, #{e.message}"
end