Class: ForemanMaintain::Config
- Inherits:
-
Object
- Object
- ForemanMaintain::Config
- Defined in:
- lib/foreman_maintain/config.rb
Instance Attribute Summary collapse
-
#backup_dir ⇒ Object
Returns the value of attribute backup_dir.
-
#completion_cache_file ⇒ Object
Returns the value of attribute completion_cache_file.
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#db_backup_dir ⇒ Object
Returns the value of attribute db_backup_dir.
-
#definitions_dirs ⇒ Object
Returns the value of attribute definitions_dirs.
-
#disable_commands ⇒ Object
Returns the value of attribute disable_commands.
-
#foreman_port ⇒ Object
Returns the value of attribute foreman_port.
-
#foreman_proxy_cert_path ⇒ Object
Returns the value of attribute foreman_proxy_cert_path.
-
#foreman_url ⇒ Object
Returns the value of attribute foreman_url.
-
#log_dir ⇒ Object
Returns the value of attribute log_dir.
-
#log_file_size ⇒ Object
Returns the value of attribute log_file_size.
-
#log_filename ⇒ Object
Returns the value of attribute log_filename.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#manage_crond ⇒ Object
Returns the value of attribute manage_crond.
-
#pre_setup_log_messages ⇒ Object
Returns the value of attribute pre_setup_log_messages.
-
#storage_file ⇒ Object
Returns the value of attribute storage_file.
Instance Method Summary collapse
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #use_color? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/foreman_maintain/config.rb', line 10 def initialize() @pre_setup_log_messages = [] @config_file = .fetch(:config_file, config_file_path) @options = load_config @definitions_dirs = @options.fetch(:definitions_dirs, [File.join(source_path, 'definitions')]) load_log_configs load_backup_dir_paths load_cron_option @foreman_proxy_cert_path = @options.fetch(:foreman_proxy_cert_path, '/etc/foreman') @completion_cache_file = File.( @options.fetch(:completion_cache_file, '~/.cache/foreman_maintain_completion.yml') ) @disable_commands = @options.fetch(:disable_commands, []) @foreman_url = @options.fetch(:foreman_url) { `hostname -f`.chomp } @foreman_port = @options.fetch(:foreman_port, 443) end |
Instance Attribute Details
#backup_dir ⇒ Object
Returns the value of attribute backup_dir.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def backup_dir @backup_dir end |
#completion_cache_file ⇒ Object
Returns the value of attribute completion_cache_file.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def completion_cache_file @completion_cache_file end |
#config_file ⇒ Object
Returns the value of attribute config_file.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def config_file @config_file end |
#db_backup_dir ⇒ Object
Returns the value of attribute db_backup_dir.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def db_backup_dir @db_backup_dir end |
#definitions_dirs ⇒ Object
Returns the value of attribute definitions_dirs.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def definitions_dirs @definitions_dirs end |
#disable_commands ⇒ Object
Returns the value of attribute disable_commands.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def disable_commands @disable_commands end |
#foreman_port ⇒ Object
Returns the value of attribute foreman_port.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def foreman_port @foreman_port end |
#foreman_proxy_cert_path ⇒ Object
Returns the value of attribute foreman_proxy_cert_path.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def foreman_proxy_cert_path @foreman_proxy_cert_path end |
#foreman_url ⇒ Object
Returns the value of attribute foreman_url.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def foreman_url @foreman_url end |
#log_dir ⇒ Object
Returns the value of attribute log_dir.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def log_dir @log_dir end |
#log_file_size ⇒ Object
Returns the value of attribute log_file_size.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def log_file_size @log_file_size end |
#log_filename ⇒ Object
Returns the value of attribute log_filename.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def log_filename @log_filename end |
#log_level ⇒ Object
Returns the value of attribute log_level.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def log_level @log_level end |
#manage_crond ⇒ Object
Returns the value of attribute manage_crond.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def manage_crond @manage_crond end |
#pre_setup_log_messages ⇒ Object
Returns the value of attribute pre_setup_log_messages.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def @pre_setup_log_messages end |
#storage_file ⇒ Object
Returns the value of attribute storage_file.
4 5 6 |
# File 'lib/foreman_maintain/config.rb', line 4 def storage_file @storage_file end |
Instance Method Details
#use_color? ⇒ Boolean
28 29 30 31 |
# File 'lib/foreman_maintain/config.rb', line 28 def use_color? ENV['TERM'] && ENV.fetch('NO_COLOR', '') == '' && \ system('command -v tput', out: File.open('/dev/null')) && `tput colors`.to_i > 0 end |