Class: Thrust::Config

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

Constant Summary collapse

THRUST_VERSION =
'0.5'
THRUST_ROOT =
File.expand_path('../..', __FILE__)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relative_project_root, config) ⇒ Config

Returns a new instance of Config.



28
29
30
31
32
33
# File 'lib/thrust/config.rb', line 28

def initialize(relative_project_root, config)
  @project_root = File.expand_path(relative_project_root)
  @build_dir = File.join(project_root, 'build')
  @app_config = Thrust::AppConfig.new(config)
  verify_configuration
end

Instance Attribute Details

#app_configObject (readonly)

Returns the value of attribute app_config.



7
8
9
# File 'lib/thrust/config.rb', line 7

def app_config
  @app_config
end

#build_dirObject (readonly)

Returns the value of attribute build_dir.



7
8
9
# File 'lib/thrust/config.rb', line 7

def build_dir
  @build_dir
end

#project_rootObject (readonly)

Returns the value of attribute project_root.



7
8
9
# File 'lib/thrust/config.rb', line 7

def project_root
  @project_root
end

Class Method Details

.make(relative_project_root, config_file) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/thrust/config.rb', line 12

def self.make(relative_project_root, config_file)
  begin
    config_file_contents = YAML.load_file(config_file)
  rescue Errno::ENOENT
    puts ""
    puts "  Missing thrust.yml. Create by running:\n".red
    puts "      cp thrust.example.yml thrust.yml".blue
    exit 1
  rescue Psych::SyntaxError
    puts ""
    puts "  Malformed thrust.yml.".red
    exit 1
  end
  new(relative_project_root, config_file_contents)
end