Class: Thrust::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/thrust/config_loader.rb

Defined Under Namespace

Classes: ConfigError, InvalidVersionConfigError, MalformedConfigError, MissingConfigError

Constant Summary collapse

THRUST_VERSION =
'0.6'

Class Method Summary collapse

Class Method Details

.load_configuration(relative_project_root, config_file, out = STDERR) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/thrust/config_loader.rb', line 14

def self.load_configuration(relative_project_root, config_file, out = STDERR)
  begin
    config = YAML.load_file(config_file)
  rescue Errno::ENOENT
    out.puts ""
    out.puts "  Missing thrust.yml. Create by running:\n".red
    out.puts "      cp thrust.example.yml thrust.yml".blue
    raise MissingConfigError
  rescue Psych::SyntaxError
    out.puts ""
    out.puts "  Malformed thrust.yml.".red
    raise MalformedConfigError
  end

  project_root = File.expand_path(relative_project_root)
  config['project_root'] = project_root
  config['build_directory'] = File.join(project_root, 'build')

  app_config = Thrust::AppConfig.new(config)
  verify_configuration(app_config, out)

  app_config
end