3
4
5
6
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
42
43
|
# File 'lib/capistrano-deploy/multistage.rb', line 3
def self.load_into(configuration)
configuration.load do
set :multistage_config, Config.new(configuration)
def define_stage(*args, &block)
warn "[DEPRECATION] `define_stage` is deprecated, use `stage` instead"
stage(*args, &block)
end
def stage(name, options={}, &block)
set :default_stage, name.to_sym if options.delete(:default)
multistage_config.stage(name, options)
callbacks[:start].detect { |c| c.source == 'multistage:ensure' }.except << name.to_s
task(name) do
set :current_stage, name.to_s
options.each do |k, v|
set k, v if v
end
block.call if block
end
end
namespace :multistage do
task :ensure do
unless exists?(:current_stage)
if stage = multistage_config.inferred_stage
find_and_execute_task(stage.name)
elsif exists?(:default_stage)
find_and_execute_task(default_stage)
else
stage_names = multistage_config.stages.map(&:name)
abort "No stage specified. Please specify one of: #{stage_names.join(', ')} (e.g. `cap #{stage_names.first} #{ARGV.last}')"
end
end
end
end
on :start, 'multistage:ensure'
end
end
|