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
-
.cache_path ⇒ Object
readonly
Returns the value of attribute cache_path.
-
.config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
.data_path ⇒ Object
readonly
Returns the value of attribute data_path.
-
.log_path ⇒ Object
readonly
Returns the value of attribute log_path.
-
.root_path ⇒ Object
readonly
Returns the value of attribute root_path.
-
.tmp_path ⇒ Object
readonly
Returns the value of attribute tmp_path.
-
.user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.load_config! ⇒ Object
Tries to find and load the configuration file.
-
.update(options = {}) ⇒ Object
Setup required paths based on the given options.
Class Attribute Details
.cache_path ⇒ Object (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_file ⇒ Object (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_path ⇒ Object (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_path ⇒ Object (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_path ⇒ Object (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_path ⇒ Object (readonly)
Returns the value of attribute tmp_path.
14 15 16 |
# File 'lib/backup/config.rb', line 14 def tmp_path @tmp_path end |
.user ⇒ Object (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( = {}) root_path = [: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, [name], ending, new_root) end end |