Changeset 6500
- Timestamp:
- 04/02/07 22:44:21 (1 year ago)
- Files:
-
- tools/capistrano/lib/capistrano/recipes/deploy.rb (modified) (2 diffs)
- tools/capistrano/lib/capistrano/recipes/deploy/local_dependency.rb (modified) (1 diff)
- tools/capistrano/lib/capistrano/recipes/deploy/remote_dependency.rb (modified) (2 diffs)
- tools/capistrano/lib/capistrano/recipes/deploy/strategy/base.rb (modified) (1 diff)
- tools/capistrano/lib/capistrano/recipes/deploy/strategy/copy.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/capistrano/lib/capistrano/recipes/deploy.rb
r6497 r6500 48 48 49 49 set(:run_method) { fetch(:use_sudo, true) ? :sudo : :run } 50 51 # ========================================================================= 52 # These are helper methods that will be available to your recipes. 53 # ========================================================================= 54 55 # Auxiliary helper method for the `deploy:check' task. Lets you set up your 56 # own dependencies. 57 def depend(location, type, *args) 58 deps = fetch(:dependencies, {}) 59 deps[location] ||= {} 60 deps[location][type] ||= [] 61 deps[location][type] << args 62 set :dependencies, deps 63 end 50 64 51 65 # ========================================================================= … … 298 312 be incorrect or missing. This is good for making sure a deploy has a \ 299 313 chance of working before you actually run `cap deploy'. 314 315 You can define your own dependencies, as well, using the `depend' method: 316 317 depend :remote, :gem, "tzinfo", ">=0.3.3" 318 depend :local, :command, "svn" 319 depend :remote, :directory, "/u/depot/files" 300 320 DESC 301 321 task :check, :except => { :no_release => true } do 302 322 dependencies = strategy.check! 323 324 other = fetch(:dependencies, {}) 325 other.each do |location, types| 326 types.each do |type, calls| 327 if type == :gem 328 dependencies.send(location).command(fetch(:gem_command, "gem")).or("`gem' command could not be found. Try setting :gem_command") 329 end 330 331 calls.each do |args| 332 dependencies.send(location).send(type, *args) 333 end 334 end 335 end 336 303 337 if dependencies.pass? 304 338 puts "You appear to have all necessary dependencies installed" tools/capistrano/lib/capistrano/recipes/deploy/local_dependency.rb
r6487 r6500 10 10 end 11 11 12 def expects_in_path(command)12 def command(command) 13 13 @message ||= "`#{command}' could not be found in the path on the local host" 14 14 @success = find_in_path(command) tools/capistrano/lib/capistrano/recipes/deploy/remote_dependency.rb
r6487 r6500 10 10 end 11 11 12 def expect_directory(path)12 def directory(path, options={}) 13 13 @message ||= "`#{path}' is not a directory" 14 try("test -d #{path}" )14 try("test -d #{path}", options) 15 15 self 16 16 end 17 17 18 def expect_writable(path)18 def writable(path, options={}) 19 19 @message ||= "`#{path}' is not writable" 20 try("test -w #{path}" )20 try("test -w #{path}", options) 21 21 self 22 22 end 23 23 24 def expects_in_path(command)24 def command(command, options={}) 25 25 @message ||= "`#{command}' could not be found in the path" 26 try("type -p #{command}") 26 try("type -p #{command}", options) 27 self 28 end 29 30 def gem(name, version, options={}) 31 @message ||= "gem `#{name}' #{version} could not be found" 32 gem_cmd = configuration.fetch(:gem_command, "gem") 33 try("#{gem_cmd} specification --version \"#{version}\" #{name} 2>&1 | awk 'BEGIN { s = 0 }; /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'", options) 27 34 self 28 35 end … … 45 52 private 46 53 47 def try(command )54 def try(command, options) 48 55 return unless @success # short-circuit evaluation 49 configuration.run(command ) do |ch,stream,out|56 configuration.run(command, options) do |ch,stream,out| 50 57 warn "#{ch[:host]}: #{out}" if stream == :err 51 58 end tools/capistrano/lib/capistrano/recipes/deploy/strategy/base.rb
r6487 r6500 29 29 def check! 30 30 Dependencies.new(configuration) do |d| 31 d.remote. expect_directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.")32 d.remote. expect_writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.")33 d.remote. expect_writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.")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 34 end 35 35 end tools/capistrano/lib/capistrano/recipes/deploy/strategy/copy.rb
r6487 r6500 41 41 def check! 42 42 super.check do |d| 43 d.local. expects_in_path(source.command)44 d.local. expects_in_path(compress(nil, nil).first)45 d.remote. expects_in_path(decompress(nil).first)43 d.local.command(source.command) 44 d.local.command(compress(nil, nil).first) 45 d.remote.command(decompress(nil).first) 46 46 end 47 47 end