Class: Bastion::Config
- Inherits:
-
Object
- Object
- Bastion::Config
- Defined in:
- lib/bastion/config.rb
Overview
Config class
Constant Summary collapse
- USER =
"#{ENV['HOME']}/.bastion/config"
- SYSTEM =
"/etc/bastion/config"
- ENVVAR =
"BASTION_HOST"
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #method_missing(name) ⇒ Object
- #read(file, default = nil) ⇒ Object
- #save(value) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
40 41 42 |
# File 'lib/bastion/config.rb', line 40 def method_missing(name) instance_variable_get :"@#{name}" end |
Instance Method Details
#info ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/bastion/config.rb', line 19 def info puts "System : #{@system}" puts "User : #{@user}" puts "Env : #{@env}" puts "Option : #{@option}" puts "Using : #{@host}" end |
#read(file, default = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/bastion/config.rb', line 27 def read(file, default = nil) return default unless File.exist?(file) value = File.read(file) value.empty? ? nil : value end |