Class: Boxes::Config

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

Overview

Stores the configuration for Boxes.

Constant Summary collapse

DEFAULTS =

The default settings for the configuration.

{
  environment_vars: [
    { 'PACKER_CACHE_DIR' => (
        Pathname.new(ENV['BOXES_HOME_DIR'] || '~/.boxes'
                    ).expand_path + 'packer_cache') }
  ],
  template_paths: [
    # the gem install directory
    File.expand_path('../../../templates', __FILE__)
  ],
  script_paths: [
    # the gem install directory
    File.expand_path('../../../scripts', __FILE__)
  ]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



42
43
44
45
46
47
48
49
# File 'lib/boxes/config.rb', line 42

def initialize
  configure_with(DEFAULTS)

  return unless .exist?

   = YAML.load_file()
  configure_with()
end

Instance Attribute Details

#environment_varsObject

A Hash of environment variables Boxes sets in the run environment.



40
41
42
# File 'lib/boxes/config.rb', line 40

def environment_vars
  @environment_vars
end

#script_pathsObject

Paths known to boxes for discovering scripts.



37
38
39
# File 'lib/boxes/config.rb', line 37

def script_paths
  @script_paths
end

#template_pathsObject

Paths known to boxes for discovering templates.



34
35
36
# File 'lib/boxes/config.rb', line 34

def template_paths
  @template_paths
end

Instance Method Details

#home_dirObject

The directory which boxes works out of.



22
23
24
25
# File 'lib/boxes/config.rb', line 22

def home_dir
  @home_dir ||= Pathname.new(
    ENV['BOXES_HOME_DIR'] || '~/.boxes').expand_path
end

#working_dirObject

The directory inside the ‘home_dir` which boxes runs builds inside of.



28
29
30
31
# File 'lib/boxes/config.rb', line 28

def working_dir
  @working_dir ||= Pathname.new(
    ENV['BOXES_WORKING_DIR'] || home_dir + 'tmp').expand_path
end