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

Inherits:
Object
  • Object
show all
Defined in:
lib/alpha_omega/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

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/alpha_omega/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.



42
43
44
45
46
47
48
# File 'lib/alpha_omega/deploy/strategy/base.rb', line 42

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/alpha_omega/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
# File 'lib/alpha_omega/deploy/strategy/base.rb', line 30

def check!
  Dependencies.new(configuration) do |d|
    d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist.")
    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/alpha_omega/deploy/strategy/base.rb', line 24

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