lib/kapify/base.rb in kapify-0.0.2 vs lib/kapify/base.rb in kapify-0.0.3

- old
+ new

@@ -1,10 +1,32 @@ Capistrano::Configuration.instance.load do def set_default(name, *args, &block) set(name, *args, &block) unless exists?(name) end - set_default(:templates_path, "config/deploy/templates") + def close_sessions + sessions.values.each { |session| session.close } + sessions.clear + end + + def as_user(user_name) + old_user = user + set :user, user_name + close_sessions + begin + yield + ensure + set :user, old_user + close_sessions + end + end + + set_default(:templates_path, "#{Dir.pwd}/config/deploy/templates") + + def template(from, to) + erb = File.read(File.expand_path("#{templates_path}/#{from}", __FILE__)) + put ERB.new(erb).result(binding), to + end def kapify_template(generator, template_name, target) config_file = "#{templates_path}/#{template_name}" # if no customized file, proceed with default unless File.exists?(config_file)