vagrant/lib/hobo/config.rb

76 lines
1.3 KiB
Ruby
Raw Normal View History

2010-01-22 05:54:23 +00:00
module Hobo
2010-02-02 06:14:40 +00:00
def self.config
Config.config
2010-01-22 08:37:50 +00:00
end
2010-02-02 06:14:40 +00:00
class Config
@config = nil
@config_runners = []
class <<self
def config
@config ||= Config::Top.new
end
def config_runners
@config_runners ||= []
end
def run(&block)
config_runners << block
end
def execute!
config_runners.each do |block|
block.call(config)
end
end
end
2010-01-22 05:54:23 +00:00
end
2010-02-02 06:14:40 +00:00
class Config
class Base
def [](key)
send(key)
end
end
2010-01-30 06:23:33 +00:00
2010-02-02 06:14:40 +00:00
class SSHConfig < Base
attr_accessor :username
attr_accessor :password
2010-02-02 06:14:40 +00:00
attr_accessor :host
attr_accessor :forwarded_port_key
2010-02-02 06:14:40 +00:00
attr_accessor :max_tries
end
2010-02-02 06:14:40 +00:00
class VMConfig < Base
attr_accessor :base
attr_accessor :base_mac
attr_reader :forwarded_ports
def initialize
@forwarded_ports = {}
end
def forward_port(name, guestport, hostport, protocol="TCP")
forwarded_ports[name] = {
:guestport => guestport,
:hostport => hostport,
:protocol => protocol
}
end
end
2010-02-02 06:14:40 +00:00
class Top < Base
attr_accessor :dotfile_name
attr_reader :ssh
attr_reader :vm
2010-02-02 06:14:40 +00:00
def initialize
@ssh = SSHConfig.new
@vm = VMConfig.new
end
end
end
2010-01-22 05:54:23 +00:00
end