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

Class | Capistrano::Deploy::Strategy::Base
In: | lib/capistrano/recipes/deploy/strategy/base.rb lib/capistrano/recipes/deploy/strategy/base.rb
Parent: | Object

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

### Methods

check! check! deploy! deploy! method_missing method_missing new new system system

### Attributes

configuration | [R] |
configuration | [R] |

### Public Class methods

new(config={})

Instantiates a strategy with a reference to the given configuration.

[Source]

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

new(config={})

Instantiates a strategy with a reference to the given configuration.

[Source]

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

### Public Instance methods

check!()

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

[Source]

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

check!()

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

[Source]

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

deploy!()

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.

[Source]

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

deploy!()

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.

[Source]

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

### Protected Instance methods

method_missing(sym, *args, &block)

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

[Source]

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

method_missing(sym, *args, &block)

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

[Source]

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

system(*args)

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

[Source]

        # File lib/capistrano/recipes/deploy/strategy/base.rb, line 50
    50:           def system(*args)
    51:             cmd = args.join(' ')
    52:             if RUBY_PLATFORM =~ /win32/
    53:                                                         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://
    54:               cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D
    55:               cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D
    56:               logger.trace "executing locally: #{cmd}"
    57:               super(cmd)
    58:             else
    59:               logger.trace "executing locally: #{cmd}"
    60:               super
    61:             end
    62:           end

system(*args)

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

[Source]

        # File lib/capistrano/recipes/deploy/strategy/base.rb, line 50
    50:           def system(*args)
    51:             cmd = args.join(' ')
    52:             if RUBY_PLATFORM =~ /win32/
    53:                                                         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://
    54:               cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D
    55:               cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D
    56:               logger.trace "executing locally: #{cmd}"
    57:               super(cmd)
    58:             else
    59:               logger.trace "executing locally: #{cmd}"
    60:               super
    61:             end
    62:           end

[Validate]