Class: UBSafe::Config
- Inherits:
-
Object
- Object
- UBSafe::Config
- Defined in:
- lib/ubsafe/ubsafe_config.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.config ⇒ UBSafe::Config
Get configuration settings.
-
.reset ⇒ Object
Reset the configuration settings.
Instance Method Summary collapse
-
#full_options(backup_name) ⇒ Hash
Get the full set of configuration options for the specified backup.
-
#load(args = nil) ⇒ Object
Load a Config instance.
-
#log ⇒ Logging::Logger
Get logger.
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/ubsafe/ubsafe_config.rb', line 10 def @options end |
Class Method Details
.config ⇒ UBSafe::Config
Get configuration settings
19 20 21 22 23 24 |
# File 'lib/ubsafe/ubsafe_config.rb', line 19 def config if (not defined?(@@config_instance)) or @@config_instance.nil? @@config_instance = UBSafe::Config.new end return @@config_instance end |
.reset ⇒ Object
Reset the configuration settings
29 30 31 |
# File 'lib/ubsafe/ubsafe_config.rb', line 29 def reset @@config_instance = nil end |
Instance Method Details
#full_options(backup_name) ⇒ Hash
Get the full set of configuration options for the specified backup
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ubsafe/ubsafe_config.rb', line 70 def (backup_name) = {} # Get backup defaults .merge!(@options[:backup_defaults].dup_contents_1_level) # Get the specific backup definition unless @options[:backups].has_key?(backup_name.to_sym) @logger.fatal("The backup name specified '#{backup_name}' has no configuration defined in #{@options[:config_file]}") raise Exception.new("Non-existent backup specified '#{backup_name}'") end .merge!(@options[:backups][backup_name.to_sym].dup_contents_1_level) return nil unless [:enabled] [:backup_name] = backup_name.to_s unless [:backup_name] # Expand the backup host reference selected_host = [:backup_host] .merge!(@options[:backup_hosts][selected_host].dup_contents_1_level) # Expand the backup type reference selected_backup_type = [:backup_type] .merge!(@options[:backup_types][selected_backup_type].dup_contents_1_level) return end |
#load(args = nil) ⇒ Object
Load a Config instance
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ubsafe/ubsafe_config.rb', line 53 def load(args = nil) @options[:config_file] = ENV['UBSAFE_CONFIG_FILE'] unless ENV['UBSAFE_CONFIG_FILE'].nil? #puts "UBConfig.load After env check @options #{@options.inspect}" @options.merge!(parse_args(args)) #puts "UBConfig.load After merge @options #{@options.inspect}" if @options[:config_file] @options.merge!(load_config_file(@options[:config_file])) end configure_logging end |
#log ⇒ Logging::Logger
Get logger
95 96 97 |
# File 'lib/ubsafe/ubsafe_config.rb', line 95 def log return defined?(@logger) ? @logger : nil end |