Class | Capistrano::Deploy::Strategy::Base |
In: |
lib/capistrano/recipes/deploy/strategy/base.rb
lib/capistrano/recipes/deploy/strategy/base.rb |
Parent: | Object |
This class defines the abstract interface for all Capistrano deployment strategies. Subclasses must implement at least the deploy! method.
configuration | [R] | |
configuration | [R] |
Instantiates a strategy with a reference to the given configuration.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 14 14: def initialize(config={}) 15: @configuration = config 16: end
Instantiates a strategy with a reference to the given configuration.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 14 14: def initialize(config={}) 15: @configuration = config 16: end
Performs a check on the remote hosts to determine whether everything is setup such that a deploy could succeed.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 29 29: def check! 30: Dependencies.new(configuration) do |d| 31: d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.") 32: d.remote.writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.") 33: d.remote.writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.") 34: end 35: end
Performs a check on the remote hosts to determine whether everything is setup such that a deploy could succeed.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 29 29: def check! 30: Dependencies.new(configuration) do |d| 31: d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.") 32: d.remote.writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.") 33: d.remote.writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.") 34: end 35: end
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.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 23 23: def deploy! 24: raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}" 25: end
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.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 23 23: def deploy! 24: raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}" 25: end
This is to allow helper methods like "run" and "put" to be more easily accessible to strategy implementations.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 41 41: def method_missing(sym, *args, &block) 42: if configuration.respond_to?(sym) 43: configuration.send(sym, *args, &block) 44: else 45: super 46: end 47: end
This is to allow helper methods like "run" and "put" to be more easily accessible to strategy implementations.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 41 41: def method_missing(sym, *args, &block) 42: if configuration.respond_to?(sym) 43: configuration.send(sym, *args, &block) 44: else 45: super 46: end 47: end
A wrapper for Kernel#system that logs the command being executed.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 50 50: def system(*args) 51: cmd = args.join(' ') 52: if RUBY_PLATFORM =~ /win32/ 53: cmd = cmd.split(/\s+/).collect {|w| w.match(/^[\w+]+:\/\//) ? w : w.gsub('/', '\\') }.join(' ') # Split command by spaces, change / by \\ unless element is a some+thing:// 54: cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D 55: cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D 56: logger.trace "executing locally: #{cmd}" 57: super(cmd) 58: else 59: logger.trace "executing locally: #{cmd}" 60: super 61: end 62: end
A wrapper for Kernel#system that logs the command being executed.
# File lib/capistrano/recipes/deploy/strategy/base.rb, line 50 50: def system(*args) 51: cmd = args.join(' ') 52: if RUBY_PLATFORM =~ /win32/ 53: cmd = cmd.split(/\s+/).collect {|w| w.match(/^[\w+]+:\/\//) ? w : w.gsub('/', '\\') }.join(' ') # Split command by spaces, change / by \\ unless element is a some+thing:// 54: cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D 55: cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D 56: logger.trace "executing locally: #{cmd}" 57: super(cmd) 58: else 59: logger.trace "executing locally: #{cmd}" 60: super 61: end 62: end