lib/capistrano/multiconfig.rb in capistrano-multiconfig-0.0.4 vs lib/capistrano/multiconfig.rb in capistrano-multiconfig-3.0.0
- old
+ new
@@ -1,2 +1,24 @@
require 'capistrano/multiconfig/configurations'
-require 'capistrano/multiconfig/ensure'
+
+include Capistrano::DSL
+
+config_root_path = File.expand_path(fetch(:config_root, "config/deploy"))
+
+config_names = Capistrano::Multiconfig::Configurations.find_names(config_root_path)
+
+config_names.each do |config_name|
+ Rake::Task.define_task(config_name) do
+ set(:config_name, config_name)
+ segments = config_name.split(":")
+ segments.size.times do |i|
+ path = File.join([config_root_path] + segments[0..i]) + '.rb'
+ load(path) if File.exists?(path)
+ end
+ end.add_description("Load #{config_name} configuration")
+end
+
+set(:config_names, config_names)
+
+def stages
+ fetch(:config_names)
+end