Module: Backup::Config
- Extended by:
- Utilities::Helpers
- Defined in:
- lib/backup/config.rb,
lib/backup/config/dsl.rb,
lib/backup/config/helpers.rb
Defined Under Namespace
Modules: Helpers Classes: DSL, Defaults, Error
Constant Summary collapse
- DEFAULTS =
{ config_file: "config.rb", data_path: ".data", tmp_path: ".tmp" }
Class Attribute Summary collapse
-
.config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
.data_path ⇒ Object
readonly
Returns the value of attribute data_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
- .hostname ⇒ Object
-
.load(options = {}) ⇒ Object
Loads the user’s
config.rband all model files.
Class Attribute Details
.config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
17 18 19 |
# File 'lib/backup/config.rb', line 17 def config_file @config_file end |
.data_path ⇒ Object (readonly)
Returns the value of attribute data_path.
17 18 19 |
# File 'lib/backup/config.rb', line 17 def data_path @data_path end |
.root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
17 18 19 |
# File 'lib/backup/config.rb', line 17 def root_path @root_path end |
.tmp_path ⇒ Object (readonly)
Returns the value of attribute tmp_path.
17 18 19 |
# File 'lib/backup/config.rb', line 17 def tmp_path @tmp_path end |
.user ⇒ Object (readonly)
Returns the value of attribute user.
17 18 19 |
# File 'lib/backup/config.rb', line 17 def user @user end |
Class Method Details
.hostname ⇒ Object
51 52 53 |
# File 'lib/backup/config.rb', line 51 def hostname @hostname ||= run(utility(:hostname)) end |
.load(options = {}) ⇒ Object
Loads the user’s config.rb and all model files.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/backup/config.rb', line 20 def load( = {}) update() # from the command line unless File.exist?(config_file) raise Error, "Could not find configuration file: '#{config_file}'." end config = File.read(config_file) version = Backup::VERSION.split(".").first unless config =~ /^# Backup v#{ version }\.x Configuration$/ raise Error, " Invalid Configuration File\n The configuration file at '\#{config_file}'\n does not appear to be a Backup v\#{version}.x configuration file.\n If you have upgraded to v\#{version}.x from a previous version,\n you need to upgrade your configuration file.\n Please see the instructions for upgrading in the Backup documentation.\n EOS\n end\n\n dsl = DSL.new\n dsl.instance_eval(config, config_file)\n\n update(dsl._config_options) # from config.rb\n update(options) # command line takes precedence\n\n Dir[File.join(File.dirname(config_file), \"models\", \"*.rb\")].each do |model|\n dsl.instance_eval(File.read(model), model)\n end\nend\n" |