Class: Capistrano::Deploy::Strategy::Base

### Home Classes Methods

### In Files

- lib/capistrano/recipes/deploy/strategy/base.rb

### Parent

Object

### Methods

- ::new
- #check!
- #deploy!
- #method_missing
- #system

### Files

- help.txt

### Class/Module Index

Quicksearch

- Capistrano
- Capistrano::CLI
- Capistrano::CLI::Execute
- Capistrano::CLI::Execute::ClassMethods
- Capistrano::CLI::Help
- Capistrano::CLI::Options
- Capistrano::CLI::Options::ClassMethods
- Capistrano::CLI::UI
- Capistrano::CLI::UI::ClassMethods
- Capistrano::Callback
- Capistrano::Command
- Capistrano::Command::Tree
- Capistrano::Command::Tree::Branch
- Capistrano::Command::Tree::ConditionBranch
- Capistrano::Command::Tree::ConditionBranch::Evaluator
- Capistrano::Command::Tree::ElseBranch
- Capistrano::Configuration
- Capistrano::Configuration::Actions
- Capistrano::Configuration::Actions::FileTransfer
- Capistrano::Configuration::Actions::Inspect
- Capistrano::Configuration::Actions::Invocation
- Capistrano::Configuration::Actions::Invocation::ClassMethods
- Capistrano::Configuration::AliasTask
- Capistrano::Configuration::Callbacks
- Capistrano::Configuration::Connections
- Capistrano::Configuration::Execution
- Capistrano::Configuration::Loading
- Capistrano::Configuration::Loading::ClassMethods
- Capistrano::Configuration::LogFormatters
- Capistrano::Configuration::Namespaces
- Capistrano::Configuration::Namespaces::Namespace
- Capistrano::Configuration::Roles
- Capistrano::Configuration::Servers
- Capistrano::Configuration::Variables
- Capistrano::Deploy
- Capistrano::Deploy::Dependencies
- Capistrano::Deploy::LocalDependency
- Capistrano::Deploy::RemoteDependency
- Capistrano::Deploy::SCM
- Capistrano::Deploy::SCM::Accurev
- Capistrano::Deploy::SCM::Accurev::InternalRevision
- Capistrano::Deploy::SCM::Base
- Capistrano::Deploy::SCM::Base::LocalProxy
- Capistrano::Deploy::SCM::Bzr
- Capistrano::Deploy::SCM::Cvs
- Capistrano::Deploy::SCM::Darcs
- Capistrano::Deploy::SCM::Git
- Capistrano::Deploy::SCM::Mercurial
- Capistrano::Deploy::SCM::None
- Capistrano::Deploy::SCM::Perforce
- Capistrano::Deploy::SCM::Subversion
- Capistrano::Deploy::Strategy
- Capistrano::Deploy::Strategy::Base
- Capistrano::Deploy::Strategy::Checkout
- Capistrano::Deploy::Strategy::Copy
- Capistrano::Deploy::Strategy::Export
- Capistrano::Deploy::Strategy::Remote
- Capistrano::Deploy::Strategy::RemoteCache
- Capistrano::Deploy::Strategy::UnsharedRemoteCache
- Capistrano::ProcCallback
- Capistrano::Processable
- Capistrano::Processable::SessionAssociation
- Capistrano::RemoteError
- Capistrano::Role
- Capistrano::Role::DynamicServerList
- Capistrano::SSH
- Capistrano::ServerDefinition
- Capistrano::Shell
- Capistrano::TaskCallback
- Capistrano::TaskDefinition
- Capistrano::Transfer
- Capistrano::Transfer::SFTPTransferWrapper
- Capistrano::Version
- Kernel
- Object
- String

No matching classes.

# Capistrano::Deploy::Strategy::Base

This class defines the abstract interface for all Capistrano deployment strategies. Subclasses must implement at least the deploy! method.

### Attributes

configuration[R]

### Public Class Methods

new(config={}) click to toggle source

Instantiates a strategy with a reference to the given configuration.

    # File lib/capistrano/recipes/deploy/strategy/base.rb, line 15
    def initialize(config={})
      @configuration = config
    end

### Public Instance Methods

check!() click to toggle source

Performs a check on the remote hosts to determine whether everything is setup such that a deploy could succeed.

    # File lib/capistrano/recipes/deploy/strategy/base.rb, line 30
    def check!
      Dependencies.new(configuration) do |d|
        if exists?(:stage)
          d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap #{configuration[:stage]} deploy:setup'.")
        else
          d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.")
        end
        d.remote.writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.")
        d.remote.writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.")
      end
    end

deploy!() click to toggle source

Executes the necessary commands to deploy the revision of the source code identified by the `revision` variable. Additionally, this should write the value of the `revision` variable to a file called REVISION, in the base of the deployed revision. This file is used by other tasks, to perform diffs and such.

    # File lib/capistrano/recipes/deploy/strategy/base.rb, line 24
    def deploy!
      raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}"
    end

### Protected Instance Methods

method_missing(sym, *args, &block) click to toggle source

This is to allow helper methods like "run" and "put" to be more easily accessible to strategy implementations.

    # File lib/capistrano/recipes/deploy/strategy/base.rb, line 46
    def method_missing(sym, *args, &block)
      if configuration.respond_to?(sym)
        configuration.send(sym, *args, &block)
      else
        super
      end
    end

system(*args) click to toggle source

A wrapper for Kernel#system that logs the command being executed.

    # File lib/capistrano/recipes/deploy/strategy/base.rb, line 55
    def system(*args)
      cmd = args.join(' ')
      result = nil
      if RUBY_PLATFORM =~ /win32/
        cmd = cmd.split(/\s+/).collect {|w| w.match(/^[\w+]+:\/\//) ? w : w.gsub('/', '\') }.join(' ') # Split command by spaces, change / by \\ unless element is a some+thing://
        cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D
        cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D
        logger.trace "executing locally: #{cmd}"
        elapsed = Benchmark.realtime do
          result = super(cmd)
        end
      else
        logger.trace "executing locally: #{cmd}"
        elapsed = Benchmark.realtime do
          result = super
        end
      end

      logger.trace "command finished in #{(elapsed * 1000).round}ms"
      result
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.