Class: Runbook::Configuration
- Inherits:
-
Object
- Object
- Runbook::Configuration
- Defined in:
- lib/runbook/configuration.rb
Constant Summary collapse
- GlobalConfigFile =
"/etc/runbook.conf"
- ProjectConfigFile =
"Runbookfile"
- UserConfigFile =
".runbook.conf"
Instance Attribute Summary collapse
-
#enable_sudo_prompt ⇒ Object
Returns the value of attribute enable_sudo_prompt.
-
#ssh_kit ⇒ Object
Returns the value of attribute ssh_kit.
-
#use_same_sudo_password ⇒ Object
Returns the value of attribute use_same_sudo_password.
Class Method Summary collapse
- ._load_cli_config ⇒ Object
- ._load_global_config ⇒ Object
- ._load_project_config ⇒ Object
- ._load_user_config ⇒ Object
- .cli_config_file ⇒ Object
- .cli_config_file=(cli_config_file) ⇒ Object
- .load_config ⇒ Object
- .loaded ⇒ Object
- .loaded=(loaded) ⇒ Object
- .reconfigure ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/runbook/configuration.rb', line 90 def initialize self.ssh_kit = SSHKit.config ssh_kit.output = Airbrussh::Formatter.new( $stdout, banner: nil, command_output: true, ) self.enable_sudo_prompt = true self.use_same_sudo_password = true end |
Instance Attribute Details
#enable_sudo_prompt ⇒ Object
Returns the value of attribute enable_sudo_prompt.
23 24 25 |
# File 'lib/runbook/configuration.rb', line 23 def enable_sudo_prompt @enable_sudo_prompt end |
#ssh_kit ⇒ Object
Returns the value of attribute ssh_kit.
22 23 24 |
# File 'lib/runbook/configuration.rb', line 22 def ssh_kit @ssh_kit end |
#use_same_sudo_password ⇒ Object
Returns the value of attribute use_same_sudo_password.
24 25 26 |
# File 'lib/runbook/configuration.rb', line 24 def use_same_sudo_password @use_same_sudo_password end |
Class Method Details
._load_cli_config ⇒ Object
84 85 86 87 88 |
# File 'lib/runbook/configuration.rb', line 84 def self._load_cli_config if cli_config_file && File.exist?(cli_config_file) load(cli_config_file) end end |
._load_global_config ⇒ Object
62 63 64 |
# File 'lib/runbook/configuration.rb', line 62 def self._load_global_config load(GlobalConfigFile) if File.exist?(GlobalConfigFile) end |
._load_project_config ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/runbook/configuration.rb', line 66 def self._load_project_config dir = Dir.pwd loop do config_path = File.join(dir, ProjectConfigFile) if File.exist?(config_path) load(config_path) return end break if File.identical?(dir, "/") dir = File.join(dir, "..") end end |
._load_user_config ⇒ Object
79 80 81 82 |
# File 'lib/runbook/configuration.rb', line 79 def self._load_user_config user_config_file = File.join(ENV["HOME"], UserConfigFile) load(user_config_file) if File.exist?(user_config_file) end |
.cli_config_file ⇒ Object
30 31 32 |
# File 'lib/runbook/configuration.rb', line 30 def self.cli_config_file @cli_config_file end |
.cli_config_file=(cli_config_file) ⇒ Object
34 35 36 |
# File 'lib/runbook/configuration.rb', line 34 def self.cli_config_file=(cli_config_file) @cli_config_file = cli_config_file end |
.load_config ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/runbook/configuration.rb', line 46 def self.load_config return if @loaded @loaded = true _load_global_config _load_project_config _load_user_config _load_cli_config # Set defaults Runbook.configure end |
.loaded ⇒ Object
38 39 40 |
# File 'lib/runbook/configuration.rb', line 38 def self.loaded @loaded end |
.loaded=(loaded) ⇒ Object
42 43 44 |
# File 'lib/runbook/configuration.rb', line 42 def self.loaded=(loaded) @loaded = loaded end |
.reconfigure ⇒ Object
57 58 59 60 |
# File 'lib/runbook/configuration.rb', line 57 def self.reconfigure @loaded = false load_config end |