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.



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

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.



41
42
43
44
45
46
47
# File 'lib/capistrano/recipes/deploy/strategy/base.rb', line 41

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.



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

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.



29
30
31
32
33
34
35
# File 'lib/capistrano/recipes/deploy/strategy/base.rb', line 29

def check!
  Dependencies.new(configuration) do |d|
    d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.")
    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)


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

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