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

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/recipes/deploy/strategy/base.rb

Overview

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

Direct Known Subclasses

Copy, Remote

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Base

Instantiates a strategy with a reference to the given configuration.



15
16
17
# File 'lib/capistrano/recipes/deploy/strategy/base.rb', line 15

def initialize(config={})
  @configuration = config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object (protected)

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



46
47
48
49
50
51
52
# 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

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



12
13
14
# File 'lib/capistrano/recipes/deploy/strategy/base.rb', line 12

def configuration
  @configuration
end

Instance Method Details

#check!Object

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



30
31
32
33
34
35
36
37
38
39
40
# 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!Object

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.

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/capistrano/recipes/deploy/strategy/base.rb', line 24

def deploy!
  raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}"
end