Module: Backup::Config

Defined in:
lib/backup/config.rb

Constant Summary collapse

DEFAULTS =
{
  :config_file  => 'config.rb',
  :data_path    => 'data',
  :log_path     => 'log',
  :cache_path   => '.cache',
  :tmp_path     => '.tmp'
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_pathObject (readonly)

Returns the value of attribute cache_path.



14
15
16
# File 'lib/backup/config.rb', line 14

def cache_path
  @cache_path
end

.config_fileObject (readonly)

Returns the value of attribute config_file.



14
15
16
# File 'lib/backup/config.rb', line 14

def config_file
  @config_file
end

.data_pathObject (readonly)

Returns the value of attribute data_path.



14
15
16
# File 'lib/backup/config.rb', line 14

def data_path
  @data_path
end

.log_pathObject (readonly)

Returns the value of attribute log_path.



14
15
16
# File 'lib/backup/config.rb', line 14

def log_path
  @log_path
end

.root_pathObject (readonly)

Returns the value of attribute root_path.



14
15
16
# File 'lib/backup/config.rb', line 14

def root_path
  @root_path
end

.tmp_pathObject (readonly)

Returns the value of attribute tmp_path.



14
15
16
# File 'lib/backup/config.rb', line 14

def tmp_path
  @tmp_path
end

.userObject (readonly)

Returns the value of attribute user.



14
15
16
# File 'lib/backup/config.rb', line 14

def user
  @user
end

Class Method Details

.load_config!Object

Tries to find and load the configuration file



30
31
32
33
34
35
36
37
# File 'lib/backup/config.rb', line 30

def load_config!
  unless File.exist?(@config_file)
    raise Errors::Config::NotFoundError,
        "Could not find configuration file: '#{@config_file}'."
  end

  module_eval(File.read(@config_file), @config_file)
end

.update(options = {}) ⇒ Object

Setup required paths based on the given options



19
20
21
22
23
24
25
26
# File 'lib/backup/config.rb', line 19

def update(options = {})
  root_path = options[:root_path].to_s.strip
  new_root = root_path.empty? ? false : set_root_path(root_path)

  DEFAULTS.each do |name, ending|
    set_path_variable(name, options[name], ending, new_root)
  end
end