Class: Capistrano::Releases::Manager
- Inherits:
-
Object
- Object
- Capistrano::Releases::Manager
- Defined in:
- lib/capistrano/releases/manager.rb
Overview
Class for pushing/pulling Capistrano releases.
Class Attribute Summary collapse
-
.defaults ⇒ Object
Returns the value of attribute defaults.
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(parameters = {}) ⇒ Manager
constructor
A new instance of Manager.
- #pull ⇒ Object
- #push ⇒ Object
Constructor Details
#initialize(parameters = {}) ⇒ Manager
Returns a new instance of Manager.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/capistrano/releases/manager.rb', line 15 def initialize(parameters = {}) @params = parameters params[:bucket] ||= defaults[:bucket] || raise('bucket_name is a required parameter') params[:deploy_to] ||= defaults[:deploy_to] || raise('deploy_to is a required parameter') params[:keep_releases] ||= (defaults[:keep_releases] || 5) end |
Class Attribute Details
.defaults ⇒ Object
Returns the value of attribute defaults.
8 9 10 |
# File 'lib/capistrano/releases/manager.rb', line 8 def defaults @defaults end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/capistrano/releases/manager.rb', line 5 def params @params end |
Instance Method Details
#pull ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/capistrano/releases/manager.rb', line 48 def pull make_dirs locals = Set.new(local_releases) puts "Local releases: #{locals.to_a.inspect}" to_download_releases = remote_releases.last(params[:keep_releases]) .reject { |r| locals.include?(r) } to_download_releases.each do |r| puts "Downloading release: #{r}" download_release(r) end self.local_current = remote_current puts "Setting local current to: #{local_current}" Dir.chdir(File.join(params[:deploy_to], 'current')) download_bundle to_download_releases end |
#push ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/capistrano/releases/manager.rb', line 28 def push make_dirs remotes = Set.new(remote_releases) puts "Remote releases: #{remotes.to_a.inspect}" to_upload_releases = local_releases.reject { |r| remotes.include?(r) } to_upload_releases.each do |r| puts "Uploading release: #{r}" upload_release(r) end puts "Setting remote current to: #{remote_current}" self.remote_current = local_current upload_bundle to_upload_releases end |