Class: Capistrano::Distribution::Distributor::Abstract Abstract
- Inherits:
-
Object
- Object
- Capistrano::Distribution::Distributor::Abstract
- Defined in:
- lib/capistrano/distribution/distributor/abstract.rb
Overview
Subclass and override #check and #distribute to create a distributor.
An abstract distributor upon which all distributors should ultimately be based.
See the existing concrete distributor definitions for examples.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
private
The Capistrano context in which the distributor will operate.
-
#repo_id ⇒ Object
readonly
private
A unique identifier for the distributor for use under #repo_path.
-
#target ⇒ Object
readonly
private
A path relative to the release location in which to distribute the artifact.
-
#url ⇒ Object
readonly
private
The source URL for the artifact to be distributed.
Instance Method Summary collapse
-
#check ⇒ Boolean
abstract
truewhen prerequisites are met andfalseotherwise. - #distribute ⇒ nil abstract
-
#initialize(context, url, opts = {}) ⇒ Abstract
constructor
A new instance of Abstract.
-
#release_path ⇒ Pathname
private
A path to the release location in which to distribute the artifact based on #target.
-
#repo_path ⇒ Pathname
private
A path under the repo location to a unique workspace for the distributor.
Constructor Details
#initialize(context, url, opts = {}) ⇒ Abstract
Returns a new instance of Abstract.
22 23 24 25 26 27 28 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 22 def initialize(context, url, opts = {}) @context = context @url = URI === url ? url : URI.parse(url) @target = opts.fetch(:target, '') @repo_id = Digest::SHA1.hexdigest(url.to_s) end |
Instance Attribute Details
#context ⇒ Object (readonly, private)
The Capistrano context in which the distributor will operate.
58 59 60 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 58 def context @context end |
#repo_id ⇒ Object (readonly, private)
A unique identifier for the distributor for use under #repo_path.
62 63 64 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 62 def repo_id @repo_id end |
#target ⇒ Object (readonly, private)
A path relative to the release location in which to distribute the artifact.
66 67 68 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 66 def target @target end |
#url ⇒ Object (readonly, private)
The source URL for the artifact to be distributed.
54 55 56 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 54 def url @url end |
Instance Method Details
#check ⇒ Boolean
Override to provide a meaningful check for prerequisites during deployment.
Returns true when prerequisites are met and false otherwise.
36 37 38 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 36 def check false end |
#distribute ⇒ nil
Override to provide meaningful distribution logic during deployment.
47 48 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 47 def distribute end |
#release_path ⇒ Pathname (private)
Returns a path to the release location in which to distribute the artifact based on #target.
71 72 73 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 71 def release_path context.release_path.join(target) end |
#repo_path ⇒ Pathname (private)
Returns a path under the repo location to a unique workspace for the distributor.
78 79 80 |
# File 'lib/capistrano/distribution/distributor/abstract.rb', line 78 def repo_path context.repo_path.join(repo_id) end |