Class: Invoker::Power::Config

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



35
36
37
# File 'lib/invoker/power/config.rb', line 35

def initialize(options = {})
  @config = options
end

Class Method Details

.config_dirObject



31
32
33
# File 'lib/invoker/power/config.rb', line 31

def self.config_dir
  File.join(Invoker.home, ".invoker")
end

.config_fileObject



27
28
29
# File 'lib/invoker/power/config.rb', line 27

def self.config_file
  File.join(Invoker.home, ".invoker", "config")
end

.create(options = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/invoker/power/config.rb', line 13

def self.create(options = {})
  if has_config?
    raise ConfigExists, "Config file already exists at location #{config_file}"
  end
  config = new(options)
  config.save
end

.deleteObject



21
22
23
24
25
# File 'lib/invoker/power/config.rb', line 21

def self.delete
  if File.exist?(config_file)
    File.delete(config_file)
  end
end

.has_config?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/invoker/power/config.rb', line 9

def self.has_config?
  File.exist?(config_file)
end

.load_configObject



39
40
41
42
# File 'lib/invoker/power/config.rb', line 39

def self.load_config
  config_hash = File.open(config_file, "r") { |fl| YAML.load(fl) }
  new(config_hash)
end

Instance Method Details

#dns_portObject



60
# File 'lib/invoker/power/config.rb', line 60

def dns_port; @config[:dns_port]; end

#dns_port=(dns_port) ⇒ Object



44
45
46
# File 'lib/invoker/power/config.rb', line 44

def dns_port=(dns_port)
  @config[:dns_port] = dns_port
end

#http_portObject



61
# File 'lib/invoker/power/config.rb', line 61

def http_port; @config[:http_port]; end

#http_port=(http_port) ⇒ Object



48
49
50
# File 'lib/invoker/power/config.rb', line 48

def http_port=(http_port)
  @config[:http_port] = http_port
end

#https_portObject



63
# File 'lib/invoker/power/config.rb', line 63

def https_port; @config[:https_port]; end

#https_port=(https_port) ⇒ Object



52
53
54
# File 'lib/invoker/power/config.rb', line 52

def https_port=(https_port)
  @config[:https_port] = https_port
end

#ipfw_rule_numberObject



62
# File 'lib/invoker/power/config.rb', line 62

def ipfw_rule_number; @config[:ipfw_rule_number]; end

#ipfw_rule_number=(ipfw_rule_number) ⇒ Object



56
57
58
# File 'lib/invoker/power/config.rb', line 56

def ipfw_rule_number=(ipfw_rule_number)
  @config[:ipfw_rule_number] = ipfw_rule_number
end

#saveObject



69
70
71
72
73
74
# File 'lib/invoker/power/config.rb', line 69

def save
  File.open(self.class.config_file, "w") do |fl|
    YAML.dump(@config, fl)
  end
  self
end

#tldObject



65
66
67
# File 'lib/invoker/power/config.rb', line 65

def tld
  @config[:tld] || Invoker.default_tld
end