Class: Minestrone::Deploy::Strategy::Base

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

Overview

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

Direct Known Subclasses

Copy, RemoteCache

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Base

Instantiates a strategy with a reference to the given configuration.



18
19
20
# File 'lib/minestrone/recipes/deploy/strategy/base.rb', line 18

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.



51
52
53
54
55
56
57
# File 'lib/minestrone/recipes/deploy/strategy/base.rb', line 51

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.



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

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.



35
36
37
38
39
40
41
42
43
44
# File 'lib/minestrone/recipes/deploy/strategy/base.rb', line 35

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


28
29
30
# File 'lib/minestrone/recipes/deploy/strategy/base.rb', line 28

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