require 'yaml'
Capistrano::Configuration.instance(true).load do
namespace :passenger_standalone do
desc "Setup server.yml in the 'deploy_to' directory"
task :setup, :roles => [:app] do
if config = fetch(:passenger_standalone, nil)
config = deep_stringify_keys(config)
unless config["rvm"] && config["rvm"]["rvm_ruby_string"]
config["rvm"] ||= {}
config["rvm"]["rvm_ruby_string"] = fetch(:rvm_ruby_string)
end
put config.to_yaml, "#{deploy_to}/server.yml"
end
end
end
def deep_stringify_keys(hash)
hash.inject({}) do |mem, (k,v)|
if v.kind_of?(Hash)
mem[k.to_s] = deep_stringify_keys(v)
else
mem[k.to_s] = v
end
mem
end
end
end