2010-02-02 06:14:40 +00:00
|
|
|
require 'forwardable'
|
|
|
|
|
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
|
|
|
|
attr_accessor :uname
|
|
|
|
attr_accessor :pass
|
|
|
|
attr_accessor :host
|
|
|
|
attr_accessor :port
|
|
|
|
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-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
|