Class: Capistrano::SCM Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/scm.rb

Overview

This class is abstract.

Base class for SCM strategy providers.

Author:

  • Hartog de Mik

Direct Known Subclasses

Git, Hg, Svn

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, strategy) ⇒ SCM

Provide a wrapper for the SCM that loads a strategy for the user.

Parameters:

  • context (Rake)

    The context in which the strategy should run

  • strategy (Module)

    A module to include into the SCM instance. The module should provide the abstract methods of Capistrano::SCM



20
21
22
23
24
# File 'lib/capistrano/scm.rb', line 20

def initialize(context, strategy)
  @context = context
  singleton = class << self; self; end
  singleton.send(:include, strategy)
end

Instance Attribute Details

#contextRake (readonly)

Returns the current value of context.

Returns:

  • (Rake)

    the current value of context



11
12
13
# File 'lib/capistrano/scm.rb', line 11

def context
  @context
end

Instance Method Details

#checkBoolean

This method is abstract.

Your implementation should check if the specified remote-repository is available.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


74
75
76
77
78
# File 'lib/capistrano/scm.rb', line 74

def check
  raise NotImplementedError.new(
    "Your SCM strategy module should provide a #check method"
  )
end

#cloneObject

This method is abstract.

Create a (new) clone of the remote-repository on the deployment target

Returns:

  • void

Raises:

  • (NotImplementedError)


86
87
88
89
90
# File 'lib/capistrano/scm.rb', line 86

def clone
  raise NotImplementedError.new(
    "Your SCM strategy module should provide a #clone method"
  )
end

#fetch(*args) ⇒ Object

Fetch a var from the context

Parameters:

  • variable (Symbol)

    The variable to fetch

  • default (Object)

    The default value if not found



50
51
52
# File 'lib/capistrano/scm.rb', line 50

def fetch(*args)
  context.fetch(*args)
end

#fetch_revisionObject

This method is abstract.

Identify the SHA of the commit that will be deployed. This will most likely involve SshKit’s capture method.

Returns:

  • void

Raises:

  • (NotImplementedError)


122
123
124
125
126
# File 'lib/capistrano/scm.rb', line 122

def fetch_revision
  raise NotImplementedError.new(
    "Your SCM strategy module should provide a #fetch_revision method"
  )
end

#releaseObject

This method is abstract.

Copy the contents of the cache-repository onto the release path

Returns:

  • void

Raises:

  • (NotImplementedError)


110
111
112
113
114
# File 'lib/capistrano/scm.rb', line 110

def release
  raise NotImplementedError.new(
    "Your SCM strategy module should provide a #release method"
  )
end

#release_pathObject

The release path according to the context



42
43
44
# File 'lib/capistrano/scm.rb', line 42

def release_path
  context.release_path
end

#repo_pathObject

The repository path according to the context



37
38
39
# File 'lib/capistrano/scm.rb', line 37

def repo_path
  context.repo_path
end

#repo_urlObject

The repository URL according to the context



32
33
34
# File 'lib/capistrano/scm.rb', line 32

def repo_url
  context.repo_url
end

#testBoolean

This method is abstract.

Your implementation should check the existence of a cache repository on the deployment target

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


61
62
63
64
65
# File 'lib/capistrano/scm.rb', line 61

def test
  raise NotImplementedError.new(
    "Your SCM strategy module should provide a #test method"
  )
end

#test!(*args) ⇒ Object

Call test in context



27
28
29
# File 'lib/capistrano/scm.rb', line 27

def test!(*args)
  context.test *args
end

#updateObject

This method is abstract.

Update the clone on the deployment target

Returns:

  • void

Raises:

  • (NotImplementedError)


98
99
100
101
102
# File 'lib/capistrano/scm.rb', line 98

def update
  raise NotImplementedError.new(
    "Your SCM strategy module should provide a #update method"
  )
end