class Boxes::Config
Stores the configuration for Boxes
.
Constants
- DEFAULTS
The default settings for the configuration.
Attributes
environment_vars[RW]
A Hash of environment variables Boxes
sets in the run environment.
script_paths[RW]
Paths known to boxes for discovering scripts.
template_paths[RW]
Paths known to boxes for discovering templates.
Public Class Methods
new()
click to toggle source
# File lib/boxes/config.rb, line 42 def initialize configure_with(DEFAULTS) return unless user_settings_file.exist? user_settings = YAML.load_file(user_settings_file) configure_with(user_settings) end
Public Instance Methods
home_dir()
click to toggle source
The directory which boxes works out of.
# File lib/boxes/config.rb, line 22 def home_dir @home_dir ||= Pathname.new( ENV['BOXES_HOME_DIR'] || '~/.boxes').expand_path end
working_dir()
click to toggle source
The directory inside the `home_dir` which boxes runs builds inside of.
# File lib/boxes/config.rb, line 28 def working_dir @working_dir ||= Pathname.new( ENV['BOXES_WORKING_DIR'] || home_dir + 'tmp').expand_path end
Private Instance Methods
configure_with(opts = {})
click to toggle source
# File lib/boxes/config.rb, line 57 def configure_with(opts = {}) # rubocop:disable Metrics/MethodLength opts.each do |k, v| next unless respond_to?("#{k}=") if v.class == Array v.each do |e| set = Set.new(send("#{k}".to_sym)) set << e send("#{k}=".to_sym, set.to_a) end else send("#{k}=".to_sym, v) end end end
user_settings_file()
click to toggle source
# File lib/boxes/config.rb, line 53 def user_settings_file home_dir + 'config.yml' end