vagrant/lib/hobo/env.rb

30 lines
727 B
Ruby
Raw Normal View History

2010-01-22 07:38:23 +00:00
module Hobo
class Env
HOME = File.expand_path('~/.hobo')
CONFIG = { File.join(HOME, 'config.yml') => '/config/default.yml' }
ENSURE = {
:files => CONFIG.merge({}), #additional files go mhia!
:dirs => [HOME] #additional dirs go mhia!
}
2010-01-22 07:38:23 +00:00
def ensure_directories
ENSURE[:dirs].each do |name|
2010-01-22 07:38:23 +00:00
Dir.mkdir(name) unless File.exists?(name)
end
end
def ensure_files
ENSURE[:files].each do |target, default|
2010-01-22 09:47:28 +00:00
File.copy(File.join(PROJECT_ROOT, default), target) unless File.exists?(target)
2010-01-22 07:38:23 +00:00
end
end
def load_config
ensure_directories
ensure_files
parsed = yield(CONFIG.keys.first)
Hobo.config!(parsed)
2010-01-22 07:38:23 +00:00
end
end
end