Class: Kdeploy::Configuration
- Inherits:
-
Object
- Object
- Kdeploy::Configuration
- Defined in:
- lib/kdeploy/configuration.rb
Overview
Configuration management for Kdeploy
Constant Summary collapse
- DEFAULT_PARALLEL =
10- DEFAULT_SSH_TIMEOUT =
30- DEFAULT_VERIFY_HOST_KEY =
:never- DEFAULT_RETRIES =
0- DEFAULT_RETRY_DELAY =
1- CONFIG_FILE_NAME =
'.kdeploy.yml'
Class Attribute Summary collapse
-
.default_parallel ⇒ Object
Returns the value of attribute default_parallel.
-
.default_retries ⇒ Object
Returns the value of attribute default_retries.
-
.default_retry_delay ⇒ Object
Returns the value of attribute default_retry_delay.
-
.default_ssh_timeout ⇒ Object
Returns the value of attribute default_ssh_timeout.
-
.default_verify_host_key ⇒ Object
Returns the value of attribute default_verify_host_key.
Class Method Summary collapse
- .find_config_file(start_dir = Dir.pwd) ⇒ Object
- .load_from_file(config_path = nil) ⇒ Object
- .reset ⇒ Object
Class Attribute Details
.default_parallel ⇒ Object
Returns the value of attribute default_parallel.
16 17 18 |
# File 'lib/kdeploy/configuration.rb', line 16 def default_parallel @default_parallel end |
.default_retries ⇒ Object
Returns the value of attribute default_retries.
16 17 18 |
# File 'lib/kdeploy/configuration.rb', line 16 def default_retries @default_retries end |
.default_retry_delay ⇒ Object
Returns the value of attribute default_retry_delay.
16 17 18 |
# File 'lib/kdeploy/configuration.rb', line 16 def default_retry_delay @default_retry_delay end |
.default_ssh_timeout ⇒ Object
Returns the value of attribute default_ssh_timeout.
16 17 18 |
# File 'lib/kdeploy/configuration.rb', line 16 def default_ssh_timeout @default_ssh_timeout end |
.default_verify_host_key ⇒ Object
Returns the value of attribute default_verify_host_key.
16 17 18 |
# File 'lib/kdeploy/configuration.rb', line 16 def default_verify_host_key @default_verify_host_key end |
Class Method Details
.find_config_file(start_dir = Dir.pwd) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kdeploy/configuration.rb', line 41 def find_config_file(start_dir = Dir.pwd) current_dir = File.(start_dir) loop do config_file = File.join(current_dir, CONFIG_FILE_NAME) return config_file if File.exist?(config_file) parent_dir = File.dirname(current_dir) break if parent_dir == current_dir current_dir = parent_dir end nil end |
.load_from_file(config_path = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kdeploy/configuration.rb', line 30 def load_from_file(config_path = nil) config_path ||= find_config_file return unless config_path && File.exist?(config_path) config = YAML.safe_load_file(config_path, permitted_classes: [Symbol]) apply_config(config) rescue StandardError => e warn "Warning: Failed to load config from #{config_path}: #{e.}" nil end |
.reset ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/kdeploy/configuration.rb', line 22 def reset @default_parallel = DEFAULT_PARALLEL @default_ssh_timeout = DEFAULT_SSH_TIMEOUT @default_verify_host_key = DEFAULT_VERIFY_HOST_KEY @default_retries = DEFAULT_RETRIES @default_retry_delay = DEFAULT_RETRY_DELAY end |