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
-
#_airbrussh_context ⇒ Object
Returns the value of attribute _airbrussh_context.
-
#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.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/runbook/configuration.rb', line 91 def initialize self.ssh_kit = SSHKit.config formatter = Airbrussh::Formatter.new( $stdout, banner: nil, command_output: true, context: AirbrusshContext, ) ssh_kit.output = formatter self._airbrussh_context = formatter.formatters.find do |fmt| fmt.is_a?(Airbrussh::ConsoleFormatter) end.context self.enable_sudo_prompt = true self.use_same_sudo_password = true end |
Instance Attribute Details
#_airbrussh_context ⇒ Object
Returns the value of attribute _airbrussh_context.
22 23 24 |
# File 'lib/runbook/configuration.rb', line 22 def _airbrussh_context @_airbrussh_context end |
#enable_sudo_prompt ⇒ Object
Returns the value of attribute enable_sudo_prompt.
24 25 26 |
# File 'lib/runbook/configuration.rb', line 24 def enable_sudo_prompt @enable_sudo_prompt end |
#ssh_kit ⇒ Object
Returns the value of attribute ssh_kit.
23 24 25 |
# File 'lib/runbook/configuration.rb', line 23 def ssh_kit @ssh_kit end |
#use_same_sudo_password ⇒ Object
Returns the value of attribute use_same_sudo_password.
25 26 27 |
# File 'lib/runbook/configuration.rb', line 25 def use_same_sudo_password @use_same_sudo_password end |
Class Method Details
._load_cli_config ⇒ Object
85 86 87 88 89 |
# File 'lib/runbook/configuration.rb', line 85 def self._load_cli_config if cli_config_file && File.exist?(cli_config_file) load(cli_config_file) end end |
._load_global_config ⇒ Object
63 64 65 |
# File 'lib/runbook/configuration.rb', line 63 def self._load_global_config load(GlobalConfigFile) if File.exist?(GlobalConfigFile) end |
._load_project_config ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/runbook/configuration.rb', line 67 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
80 81 82 83 |
# File 'lib/runbook/configuration.rb', line 80 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
31 32 33 |
# File 'lib/runbook/configuration.rb', line 31 def self.cli_config_file @cli_config_file end |
.cli_config_file=(cli_config_file) ⇒ Object
35 36 37 |
# File 'lib/runbook/configuration.rb', line 35 def self.cli_config_file=(cli_config_file) @cli_config_file = cli_config_file end |
.load_config ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/runbook/configuration.rb', line 47 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
39 40 41 |
# File 'lib/runbook/configuration.rb', line 39 def self.loaded @loaded end |
.loaded=(loaded) ⇒ Object
43 44 45 |
# File 'lib/runbook/configuration.rb', line 43 def self.loaded=(loaded) @loaded = loaded end |
.reconfigure ⇒ Object
58 59 60 61 |
# File 'lib/runbook/configuration.rb', line 58 def self.reconfigure @loaded = false load_config end |