7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/capistrano-tools/templater.rb', line 7
def self.load_into(capistrano_config)
capistrano_config.load do
namespace :templater do
task :setup, :except => { :no_release => true } do
templater = fetch(:templater, {})
location = templater.fetch(:template_dir, "templates")
templater.fetch(:templates, []).each do | template |
path_to_template = File.join(File.expand_path('../../', __FILE__), "#{location}/#{template}.yml.erb")
if File.file?(path_to_template)
config = ERB.new(File.read(path_to_template))
run "mkdir -p #{shared_path}/config"
put config.result(binding), "#{shared_path}/config/#{template}.yml"
else
puts "[WARNING] template #{path_to_template} not found"
next
end
end
end
task :symlink, :except => { :no_release => true } do
templater = fetch(:templater, {})
templater.fetch(:templates, []).each do | template |
run "ln -nfs #{shared_path}/config/#{template}.yml #{release_path}/config/#{template}.yml"
end
end
end
after "deploy:setup", "templater:setup" unless fetch(:skip_templater_setup, false)
after "deploy:finalize_update", "templater:symlink"
end
end
|