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-01-24 08:09:15 +00:00
|
|
|
|
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
|
2010-02-03 08:17:32 +00:00
|
|
|
attr_accessor :username
|
|
|
|
attr_accessor :password
|
2010-02-02 06:14:40 +00:00
|
|
|
attr_accessor :host
|
2010-02-03 08:02:12 +00:00
|
|
|
attr_accessor :forwarded_port_key
|
2010-02-02 06:14:40 +00:00
|
|
|
attr_accessor :max_tries
|
|
|
|
end
|
2010-01-30 06:03:07 +00:00
|
|
|
|
2010-02-02 06:14:40 +00:00
|
|
|
class VMConfig < Base
|
|
|
|
attr_accessor :base
|
|
|
|
attr_accessor :base_mac
|
2010-02-06 08:01:47 +00:00
|
|
|
attr_accessor :project_directory
|
2010-02-03 08:02:12 +00:00
|
|
|
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
|
2010-01-24 08:09:15 +00:00
|
|
|
end
|
|
|
|
|
2010-02-02 06:14:40 +00:00
|
|
|
class Top < Base
|
|
|
|
attr_accessor :dotfile_name
|
|
|
|
attr_reader :ssh
|
|
|
|
attr_reader :vm
|
2010-01-24 08:09:15 +00:00
|
|
|
|
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
|