Sha256: 7f1e4e2f216dea7b7e931d8f2d048ef3bb99c8fe30c75adce5a96fcee5a6c8b5

Contents?: true

Size: 1.34 KB

Versions: 42

Compression:

Stored size: 1.34 KB

Contents

require 'capistrano'

module CapistranoDeployManagement
  def self.load_into(configuration)
    configuration.load do
      @used_recipes = []

      class << self
        attr_reader :used_recipes
      end

      def use_recipe(recipe_name)
        return if @used_recipes.include?(recipe_name.to_sym)

        begin
          require "capistrano-deploy-management/#{recipe_name}"

          recipe = CapistranoDeployManagement.const_get(recipe_name.to_s.capitalize.gsub(/_(\w)/) { $1.upcase })
          recipe.load_into(self)
          @used_recipes << recipe.to_s.split('::').last.downcase.to_sym
        rescue LoadError
          abort "Did you misspell `#{recipe_name}` recipe name?"
        end
      end

      def use_recipes(*recipes)
        recipes.each do |recipe|
          use_recipe(recipe)
        end
      end

      def using_recipe?(recipe)
        used_recipes.include?(recipe.to_sym)
      end

      namespace :deploy do
        desc 'Run deploy'
        task :default do
          update
          restart
        end

        task :update do
          transaction do
            update_code
            create_symlink
          end
        end

        task :restart do
          # nothing
        end
      end
    end
  end
end

if Capistrano::Configuration.instance
  CapistranoDeployManagement.load_into(Capistrano::Configuration.instance)
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
capistrano-deploy-management-0.1.47 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.46 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.45 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.44 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.43 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.42 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.41 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.40 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.39 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.38 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.37 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.36 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.35 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.34 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.33 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.32 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.31 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.30 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.29 lib/capistrano-deploy-management.rb
capistrano-deploy-management-0.1.28 lib/capistrano-deploy-management.rb