Class: Bastion::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/bastion/config.rb

Overview

Config class

Constant Summary collapse

FILE =
"#{ENV['HOME']}/.bastion"
NAME =
"BASTION_HOST"
DEFAULT =
"bastion.example.com"

Class Method Summary collapse

Class Method Details

.loadObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bastion/config.rb', line 10

def self.load
  @@default = DEFAULT
  @@env     = ENV[NAME]
  begin
    @@file = File.open(FILE, "r").read
  rescue
    @@file = nil
  end

  @@host = @@env || @@file || @@default
end

.method_missing(name) ⇒ Object



26
27
28
# File 'lib/bastion/config.rb', line 26

def self.method_missing(name)
  class_variable_get(:"@@#{name}")
end

.save(value) ⇒ Object



22
23
24
# File 'lib/bastion/config.rb', line 22

def self.save(value)
  File.write(FILE, value)
end