Class: Invoker::Power::Config
- Inherits:
-
Object
- Object
- Invoker::Power::Config
- Defined in:
- lib/invoker/power/config.rb
Class Method Summary collapse
- .config_dir ⇒ Object
- .config_file ⇒ Object
- .create(options = {}) ⇒ Object
- .delete ⇒ Object
- .has_config? ⇒ Boolean
- .load_config ⇒ Object
Instance Method Summary collapse
- #dns_port ⇒ Object
- #dns_port=(dns_port) ⇒ Object
- #http_port ⇒ Object
- #http_port=(http_port) ⇒ Object
- #https_port ⇒ Object
- #https_port=(https_port) ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #ipfw_rule_number ⇒ Object
- #ipfw_rule_number=(ipfw_rule_number) ⇒ Object
- #save ⇒ Object
- #tld ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
35 36 37 |
# File 'lib/invoker/power/config.rb', line 35 def initialize( = {}) @config = end |
Class Method Details
.config_dir ⇒ Object
31 32 33 |
# File 'lib/invoker/power/config.rb', line 31 def self.config_dir File.join(Invoker.home, ".invoker") end |
.config_file ⇒ Object
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( = {}) if has_config? raise ConfigExists, "Config file already exists at location #{config_file}" end config = new() config.save end |
.delete ⇒ Object
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
9 10 11 |
# File 'lib/invoker/power/config.rb', line 9 def self.has_config? File.exist?(config_file) end |
.load_config ⇒ Object
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_port ⇒ Object
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_port ⇒ Object
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_port ⇒ Object
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_number ⇒ Object
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 |
#save ⇒ Object
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 |
#tld ⇒ Object
65 66 67 |
# File 'lib/invoker/power/config.rb', line 65 def tld @config[:tld] || Invoker.default_tld end |