capistrano-edge 2.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/CHANGELOG.rdoc +770 -0
  2. data/Manifest +104 -0
  3. data/README.rdoc +66 -0
  4. data/Rakefile +35 -0
  5. data/bin/cap +4 -0
  6. data/bin/capify +95 -0
  7. data/capistrano.gemspec +51 -0
  8. data/examples/sample.rb +14 -0
  9. data/lib/capistrano.rb +2 -0
  10. data/lib/capistrano/callback.rb +45 -0
  11. data/lib/capistrano/cli.rb +47 -0
  12. data/lib/capistrano/cli/execute.rb +84 -0
  13. data/lib/capistrano/cli/help.rb +125 -0
  14. data/lib/capistrano/cli/help.txt +75 -0
  15. data/lib/capistrano/cli/options.rb +224 -0
  16. data/lib/capistrano/cli/ui.rb +40 -0
  17. data/lib/capistrano/command.rb +283 -0
  18. data/lib/capistrano/configuration.rb +43 -0
  19. data/lib/capistrano/configuration/actions/file_transfer.rb +47 -0
  20. data/lib/capistrano/configuration/actions/inspect.rb +46 -0
  21. data/lib/capistrano/configuration/actions/invocation.rb +293 -0
  22. data/lib/capistrano/configuration/callbacks.rb +148 -0
  23. data/lib/capistrano/configuration/connections.rb +204 -0
  24. data/lib/capistrano/configuration/execution.rb +143 -0
  25. data/lib/capistrano/configuration/loading.rb +197 -0
  26. data/lib/capistrano/configuration/namespaces.rb +197 -0
  27. data/lib/capistrano/configuration/roles.rb +73 -0
  28. data/lib/capistrano/configuration/servers.rb +85 -0
  29. data/lib/capistrano/configuration/variables.rb +127 -0
  30. data/lib/capistrano/errors.rb +15 -0
  31. data/lib/capistrano/extensions.rb +57 -0
  32. data/lib/capistrano/logger.rb +59 -0
  33. data/lib/capistrano/processable.rb +53 -0
  34. data/lib/capistrano/recipes/compat.rb +32 -0
  35. data/lib/capistrano/recipes/deploy.rb +438 -0
  36. data/lib/capistrano/recipes/deploy/dependencies.rb +44 -0
  37. data/lib/capistrano/recipes/deploy/local_dependency.rb +54 -0
  38. data/lib/capistrano/recipes/deploy/remote_dependency.rb +105 -0
  39. data/lib/capistrano/recipes/deploy/scm.rb +19 -0
  40. data/lib/capistrano/recipes/deploy/scm/accurev.rb +169 -0
  41. data/lib/capistrano/recipes/deploy/scm/base.rb +196 -0
  42. data/lib/capistrano/recipes/deploy/scm/bzr.rb +83 -0
  43. data/lib/capistrano/recipes/deploy/scm/cvs.rb +152 -0
  44. data/lib/capistrano/recipes/deploy/scm/darcs.rb +85 -0
  45. data/lib/capistrano/recipes/deploy/scm/git.rb +274 -0
  46. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +137 -0
  47. data/lib/capistrano/recipes/deploy/scm/none.rb +44 -0
  48. data/lib/capistrano/recipes/deploy/scm/perforce.rb +138 -0
  49. data/lib/capistrano/recipes/deploy/scm/subversion.rb +121 -0
  50. data/lib/capistrano/recipes/deploy/strategy.rb +19 -0
  51. data/lib/capistrano/recipes/deploy/strategy/base.rb +79 -0
  52. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +20 -0
  53. data/lib/capistrano/recipes/deploy/strategy/copy.rb +210 -0
  54. data/lib/capistrano/recipes/deploy/strategy/export.rb +20 -0
  55. data/lib/capistrano/recipes/deploy/strategy/remote.rb +52 -0
  56. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +56 -0
  57. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +53 -0
  58. data/lib/capistrano/recipes/ext/rails-database-migrations.rb +50 -0
  59. data/lib/capistrano/recipes/ext/web-disable-enable.rb +40 -0
  60. data/lib/capistrano/recipes/standard.rb +37 -0
  61. data/lib/capistrano/recipes/templates/maintenance.rhtml +53 -0
  62. data/lib/capistrano/recipes/upgrade.rb +33 -0
  63. data/lib/capistrano/role.rb +102 -0
  64. data/lib/capistrano/server_definition.rb +56 -0
  65. data/lib/capistrano/shell.rb +260 -0
  66. data/lib/capistrano/ssh.rb +99 -0
  67. data/lib/capistrano/task_definition.rb +70 -0
  68. data/lib/capistrano/transfer.rb +216 -0
  69. data/lib/capistrano/version.rb +18 -0
  70. data/setup.rb +1346 -0
  71. data/test/cli/execute_test.rb +132 -0
  72. data/test/cli/help_test.rb +165 -0
  73. data/test/cli/options_test.rb +317 -0
  74. data/test/cli/ui_test.rb +28 -0
  75. data/test/cli_test.rb +17 -0
  76. data/test/command_test.rb +286 -0
  77. data/test/configuration/actions/file_transfer_test.rb +61 -0
  78. data/test/configuration/actions/inspect_test.rb +65 -0
  79. data/test/configuration/actions/invocation_test.rb +224 -0
  80. data/test/configuration/callbacks_test.rb +220 -0
  81. data/test/configuration/connections_test.rb +349 -0
  82. data/test/configuration/execution_test.rb +175 -0
  83. data/test/configuration/loading_test.rb +132 -0
  84. data/test/configuration/namespace_dsl_test.rb +311 -0
  85. data/test/configuration/roles_test.rb +144 -0
  86. data/test/configuration/servers_test.rb +121 -0
  87. data/test/configuration/variables_test.rb +184 -0
  88. data/test/configuration_test.rb +88 -0
  89. data/test/deploy/local_dependency_test.rb +76 -0
  90. data/test/deploy/remote_dependency_test.rb +114 -0
  91. data/test/deploy/scm/accurev_test.rb +23 -0
  92. data/test/deploy/scm/base_test.rb +55 -0
  93. data/test/deploy/scm/git_test.rb +184 -0
  94. data/test/deploy/scm/mercurial_test.rb +129 -0
  95. data/test/deploy/scm/none_test.rb +35 -0
  96. data/test/deploy/strategy/copy_test.rb +258 -0
  97. data/test/extensions_test.rb +69 -0
  98. data/test/fixtures/cli_integration.rb +5 -0
  99. data/test/fixtures/config.rb +5 -0
  100. data/test/fixtures/custom.rb +3 -0
  101. data/test/logger_test.rb +123 -0
  102. data/test/role_test.rb +11 -0
  103. data/test/server_definition_test.rb +121 -0
  104. data/test/shell_test.rb +90 -0
  105. data/test/ssh_test.rb +104 -0
  106. data/test/task_definition_test.rb +101 -0
  107. data/test/transfer_test.rb +160 -0
  108. data/test/utils.rb +38 -0
  109. metadata +321 -0
@@ -0,0 +1,32 @@
1
+ # A collection of compatibility scripts, to ease the transition between
2
+ # Capistrano 1.x and Capistrano 2.x.
3
+
4
+ # Depends on the deployment system
5
+ load 'deploy'
6
+
7
+ map = { "diff_from_last_deploy" => "deploy:pending:diff",
8
+ "update" => "deploy:update",
9
+ "update_code" => "deploy:update_code",
10
+ "symlink" => "deploy:symlink",
11
+ "restart" => "deploy:restart",
12
+ "rollback" => "deploy:rollback",
13
+ "cleanup" => "deploy:cleanup",
14
+ "disable_web" => "deploy:web:disable",
15
+ "enable_web" => "deploy:web:enable",
16
+ "cold_deploy" => "deploy:cold",
17
+ "deploy_with_migrations" => "deploy:migrations" }
18
+
19
+ map.each do |old, new|
20
+ desc "DEPRECATED: See #{new}."
21
+ eval "task(#{old.inspect}) do
22
+ warn \"[DEPRECATED] `#{old}' is deprecated. Use `#{new}' instead.\"
23
+ find_and_execute_task(#{new.inspect})
24
+ end"
25
+ end
26
+
27
+ desc "DEPRECATED: See deploy:start."
28
+ task :spinner do
29
+ warn "[DEPRECATED] `spinner' is deprecated. Use `deploy:start' instead."
30
+ set :runner, fetch(:spinner_user, "app")
31
+ deploy.start
32
+ end
@@ -0,0 +1,438 @@
1
+ require 'yaml'
2
+ require 'capistrano/recipes/deploy/scm'
3
+ require 'capistrano/recipes/deploy/strategy'
4
+
5
+ def _cset(name, *args, &block)
6
+ unless exists?(name)
7
+ set(name, *args, &block)
8
+ end
9
+ end
10
+
11
+ # =========================================================================
12
+ # These variables MUST be set in the client capfiles. If they are not set,
13
+ # the deploy will fail with an error.
14
+ # =========================================================================
15
+
16
+ _cset(:application) { abort "Please specify the name of your application, set :application, 'foo'" }
17
+ _cset(:repository) { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" }
18
+
19
+ # =========================================================================
20
+ # These variables may be set in the client capfile if their default values
21
+ # are not sufficient.
22
+ # =========================================================================
23
+
24
+ _cset :scm, :subversion
25
+ _cset :deploy_via, :checkout
26
+
27
+ _cset(:deploy_to) { "/u/apps/#{application}" }
28
+ _cset(:revision) { source.head }
29
+
30
+ # =========================================================================
31
+ # These variables should NOT be changed unless you are very confident in
32
+ # what you are doing. Make sure you understand all the implications of your
33
+ # changes if you do decide to muck with these!
34
+ # =========================================================================
35
+
36
+ _cset(:source) { Capistrano::Deploy::SCM.new(scm, self) }
37
+ _cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } }
38
+
39
+ _cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) }
40
+
41
+ _cset(:release_name) { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") }
42
+
43
+ _cset :version_dir, "releases"
44
+ _cset :shared_dir, "shared"
45
+ _cset :shared_children, %w(system log pids)
46
+ _cset :current_dir, "current"
47
+
48
+ _cset(:releases_path) { File.join(deploy_to, version_dir) }
49
+ _cset(:shared_path) { File.join(deploy_to, shared_dir) }
50
+ _cset(:current_path) { File.join(deploy_to, current_dir) }
51
+ _cset(:release_path) { File.join(releases_path, release_name) }
52
+
53
+ _cset(:releases) { capture("ls -xt #{releases_path}").split.reverse }
54
+ _cset(:current_release) { File.join(releases_path, releases.last) }
55
+ _cset(:previous_release) { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil }
56
+
57
+ _cset(:current_revision) { capture("cat #{current_path}/REVISION").chomp }
58
+ _cset(:latest_revision) { capture("cat #{current_release}/REVISION").chomp }
59
+ _cset(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp }
60
+
61
+ _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
62
+
63
+ # some tasks, like symlink, need to always point at the latest release, but
64
+ # they can also (occassionally) be called standalone. In the standalone case,
65
+ # the timestamped release_path will be inaccurate, since the directory won't
66
+ # actually exist. This variable lets tasks like symlink work either in the
67
+ # standalone case, or during deployment.
68
+ _cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
69
+
70
+ # =========================================================================
71
+ # These are helper methods that will be available to your recipes.
72
+ # =========================================================================
73
+
74
+ # Auxiliary helper method for the `deploy:check' task. Lets you set up your
75
+ # own dependencies.
76
+ def depend(location, type, *args)
77
+ deps = fetch(:dependencies, {})
78
+ deps[location] ||= {}
79
+ deps[location][type] ||= []
80
+ deps[location][type] << args
81
+ set :dependencies, deps
82
+ end
83
+
84
+ # Temporarily sets an environment variable, yields to a block, and restores
85
+ # the value when it is done.
86
+ def with_env(name, value)
87
+ saved, ENV[name] = ENV[name], value
88
+ yield
89
+ ensure
90
+ ENV[name] = saved
91
+ end
92
+
93
+ # logs the command then executes it locally.
94
+ # returns the command output as a string
95
+ def run_locally(cmd)
96
+ logger.trace "executing locally: #{cmd.inspect}" if logger
97
+ `#{cmd}`
98
+ end
99
+
100
+ # If a command is given, this will try to execute the given command, as
101
+ # described below. Otherwise, it will return a string for use in embedding in
102
+ # another command, for executing that command as described below.
103
+ #
104
+ # If :run_method is :sudo (or :use_sudo is true), this executes the given command
105
+ # via +sudo+. Otherwise is uses +run+. If :as is given as a key, it will be
106
+ # passed as the user to sudo as, if using sudo. If the :as key is not given,
107
+ # it will default to whatever the value of the :admin_runner variable is,
108
+ # which (by default) is unset.
109
+ #
110
+ # THUS, if you want to try to run something via sudo, and what to use the
111
+ # root user, you'd just to try_sudo('something'). If you wanted to try_sudo as
112
+ # someone else, you'd just do try_sudo('something', :as => "bob"). If you
113
+ # always wanted sudo to run as a particular user, you could do
114
+ # set(:admin_runner, "bob").
115
+ def try_sudo(*args)
116
+ options = args.last.is_a?(Hash) ? args.pop : {}
117
+ command = args.shift
118
+ raise ArgumentError, "too many arguments" if args.any?
119
+
120
+ as = options.fetch(:as, fetch(:admin_runner, nil))
121
+ via = fetch(:run_method, :sudo)
122
+ if command
123
+ invoke_command(command, :via => via, :as => as)
124
+ elsif via == :sudo
125
+ sudo(:as => as)
126
+ else
127
+ ""
128
+ end
129
+ end
130
+
131
+ # Same as sudo, but tries sudo with :as set to the value of the :runner
132
+ # variable (which defaults to "app").
133
+ def try_runner(*args)
134
+ options = args.last.is_a?(Hash) ? args.pop : {}
135
+ args << options.merge(:as => fetch(:runner, "app"))
136
+ try_sudo(*args)
137
+ end
138
+
139
+ # =========================================================================
140
+ # These are the tasks that are available to help with deploying web apps,
141
+ # and specifically, Rails applications. You can have cap give you a summary
142
+ # of them with `cap -T'.
143
+ # =========================================================================
144
+
145
+ namespace :deploy do
146
+ desc <<-DESC
147
+ Deploys your project. This calls both `update' and `restart'. Note that \
148
+ this will generally only work for applications that have already been deployed \
149
+ once. For a "cold" deploy, you'll want to take a look at the `deploy:cold' \
150
+ task, which handles the cold start specifically.
151
+ DESC
152
+ task :default do
153
+ update
154
+ # restart
155
+ end
156
+
157
+ [:start, :stop, :restart].each do |deprecated_task|
158
+ desc "#{deprecated_task.to_s} is deprecated. Please see "
159
+ task deprecated_task do
160
+
161
+ end
162
+ end
163
+
164
+
165
+
166
+ desc <<-DESC
167
+ Prepares one or more servers for deployment. Before you can use any \
168
+ of the Capistrano deployment tasks with your project, you will need to \
169
+ make sure all of your servers have been prepared with `cap deploy:setup'. When \
170
+ you add a new server to your cluster, you can easily run the setup task \
171
+ on just that server by specifying the HOSTS environment variable:
172
+
173
+ $ cap HOSTS=new.server.com deploy:setup
174
+
175
+ It is safe to run this task on servers that have already been set up; it \
176
+ will not destroy any deployed revisions or data.
177
+ DESC
178
+ task :setup, :except => { :no_release => true } do
179
+ dirs = [deploy_to, releases_path, shared_path]
180
+ dirs += shared_children.map { |d| File.join(shared_path, d) }
181
+ run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
182
+ unless user.nil?
183
+ run "#{try_sudo} chown -R #{user}:#{user} #{dirs.join(' ')}"
184
+ end
185
+ end
186
+
187
+ desc <<-DESC
188
+ Copies your project and updates the symlink. It does this in a \
189
+ transaction, so that if either `update_code' or `symlink' fail, all \
190
+ changes made to the remote servers will be rolled back, leaving your \
191
+ system in the same state it was in before `update' was invoked. Usually, \
192
+ you will want to call `deploy' instead of `update', but `update' can be \
193
+ handy if you want to deploy, but not immediately restart your application.
194
+ DESC
195
+ task :update do
196
+ transaction do
197
+ update_code
198
+ symlink
199
+ end
200
+ end
201
+
202
+ desc <<-DESC
203
+ Copies your project to the remote servers. This is the first stage \
204
+ of any deployment; moving your updated code and assets to the deployment \
205
+ servers. You will rarely call this task directly, however; instead, you \
206
+ should call the `deploy' task (to do a complete deploy) or the `update' \
207
+ task (if you want to perform the `restart' task separately).
208
+
209
+ You will need to make sure you set the :scm variable to the source \
210
+ control software you are using (it defaults to :subversion), and the \
211
+ :deploy_via variable to the strategy you want to use to deploy (it \
212
+ defaults to :checkout).
213
+ DESC
214
+ task :update_code, :except => { :no_release => true } do
215
+ on_rollback { run "rm -rf #{release_path}; true" }
216
+ strategy.deploy!
217
+ finalize_update
218
+ end
219
+
220
+ desc <<-DESC
221
+ [internal] Touches up the released code. This is called by update_code \
222
+ after the basic deploy finishes. It assumes a Rails project was deployed, \
223
+ so if you are deploying something else, you may want to override this \
224
+ task with your own environment's requirements.
225
+
226
+ This task will make the release group-writable (if the :group_writable \
227
+ variable is set to true, which is the default). It will then set up \
228
+ symlinks to the shared directory for the log, system, and tmp/pids \
229
+ directories, and will lastly touch all assets in public/images, \
230
+ public/stylesheets, and public/javascripts so that the times are \
231
+ consistent (so that asset timestamping works). This touch process \
232
+ is only carried out if the :normalize_asset_timestamps variable is \
233
+ set to true, which is the default.
234
+ DESC
235
+ task :finalize_update, :except => { :no_release => true } do
236
+ run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
237
+
238
+ # mkdir -p is making sure that the directories are there for some SCM's that don't
239
+ # save empty folders
240
+ run <<-CMD
241
+ rm -rf #{latest_release}/log #{latest_release}/public/system #{latest_release}/tmp/pids &&
242
+ mkdir -p #{latest_release}/public &&
243
+ mkdir -p #{latest_release}/tmp &&
244
+ ln -s #{shared_path}/log #{latest_release}/log &&
245
+ ln -s #{shared_path}/system #{latest_release}/public/system &&
246
+ ln -s #{shared_path}/pids #{latest_release}/tmp/pids
247
+ CMD
248
+
249
+ if fetch(:normalize_asset_timestamps, true)
250
+ stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S")
251
+ asset_paths = %w(images stylesheets javascripts).map { |p| "#{latest_release}/public/#{p}" }.join(" ")
252
+ run "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" }
253
+ end
254
+ end
255
+
256
+ desc <<-DESC
257
+ Updates the symlink to the most recently deployed version. Capistrano works \
258
+ by putting each new release of your application in its own directory. When \
259
+ you deploy a new version, this task's job is to update the `current' symlink \
260
+ to point at the new version. You will rarely need to call this task \
261
+ directly; instead, use the `deploy' task (which performs a complete \
262
+ deploy, including `restart') or the 'update' task (which does everything \
263
+ except `restart').
264
+ DESC
265
+ task :symlink, :except => { :no_release => true } do
266
+ on_rollback do
267
+ if previous_release
268
+ run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
269
+ else
270
+ logger.important "no previous release to rollback to, rollback of symlink skipped"
271
+ end
272
+ end
273
+
274
+ run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
275
+ end
276
+
277
+ desc <<-DESC
278
+ Copy files to the currently deployed version. This is useful for updating \
279
+ files piecemeal, such as when you need to quickly deploy only a single \
280
+ file. Some files, such as updated templates, images, or stylesheets, \
281
+ might not require a full deploy, and especially in emergency situations \
282
+ it can be handy to just push the updates to production, quickly.
283
+
284
+ To use this task, specify the files and directories you want to copy as a \
285
+ comma-delimited list in the FILES environment variable. All directories \
286
+ will be processed recursively, with all files being pushed to the \
287
+ deployment servers.
288
+
289
+ $ cap deploy:upload FILES=templates,controller.rb
290
+
291
+ Dir globs are also supported:
292
+
293
+ $ cap deploy:upload FILES='config/apache/*.conf'
294
+ DESC
295
+ task :upload, :except => { :no_release => true } do
296
+ files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten
297
+ abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty?
298
+
299
+ files.each { |file| top.upload(file, File.join(current_path, file)) }
300
+ end
301
+
302
+ namespace :rollback do
303
+ desc <<-DESC
304
+ [internal] Points the current symlink at the previous revision.
305
+ This is called by the rollback sequence, and should rarely (if
306
+ ever) need to be called directly.
307
+ DESC
308
+ task :revision, :except => { :no_release => true } do
309
+ if previous_release
310
+ run "rm #{current_path}; ln -s #{previous_release} #{current_path}"
311
+ else
312
+ abort "could not rollback the code because there is no prior release"
313
+ end
314
+ end
315
+
316
+ desc <<-DESC
317
+ [internal] Removes the most recently deployed release.
318
+ This is called by the rollback sequence, and should rarely
319
+ (if ever) need to be called directly.
320
+ DESC
321
+ task :cleanup, :except => { :no_release => true } do
322
+ run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
323
+ end
324
+
325
+ desc <<-DESC
326
+ Rolls back to the previously deployed version. The `current' symlink will \
327
+ be updated to point at the previously deployed version, and then the \
328
+ current release will be removed from the servers.
329
+ DESC
330
+ task :code, :except => { :no_release => true } do
331
+ revision
332
+ cleanup
333
+ end
334
+
335
+ desc <<-DESC
336
+ Rolls back to a previous version and restarts. This is handy if you ever \
337
+ discover that you've deployed a lemon; `cap rollback' and you're right \
338
+ back where you were, on the previously deployed version.
339
+ DESC
340
+ task :default do
341
+ revision
342
+ cleanup
343
+ end
344
+ end
345
+
346
+ desc <<-DESC
347
+ Clean up old releases. By default, the last 5 releases are kept on each \
348
+ server (though you can change this with the keep_releases variable). All \
349
+ other deployed revisions are removed from the servers. By default, this \
350
+ will use sudo to clean up the old releases, but if sudo is not available \
351
+ for your environment, set the :use_sudo variable to false instead.
352
+ DESC
353
+ task :cleanup, :except => { :no_release => true } do
354
+ count = fetch(:keep_releases, 5).to_i
355
+ if count >= releases.length
356
+ logger.important "no old releases to clean up"
357
+ else
358
+ logger.info "keeping #{count} of #{releases.length} deployed releases"
359
+
360
+ directories = (releases - releases.last(count)).map { |release|
361
+ File.join(releases_path, release) }.join(" ")
362
+
363
+ try_sudo "rm -rf #{directories}"
364
+ end
365
+ end
366
+
367
+ desc <<-DESC
368
+ Test deployment dependencies. Checks things like directory permissions, \
369
+ necessary utilities, and so forth, reporting on the things that appear to \
370
+ be incorrect or missing. This is good for making sure a deploy has a \
371
+ chance of working before you actually run `cap deploy'.
372
+
373
+ You can define your own dependencies, as well, using the `depend' method:
374
+
375
+ depend :remote, :gem, "tzinfo", ">=0.3.3"
376
+ depend :local, :command, "svn"
377
+ depend :remote, :directory, "/u/depot/files"
378
+ DESC
379
+ task :check, :except => { :no_release => true } do
380
+ dependencies = strategy.check!
381
+
382
+ other = fetch(:dependencies, {})
383
+ other.each do |location, types|
384
+ types.each do |type, calls|
385
+ if type == :gem
386
+ dependencies.send(location).command(fetch(:gem_command, "gem")).or("`gem' command could not be found. Try setting :gem_command")
387
+ end
388
+
389
+ calls.each do |args|
390
+ dependencies.send(location).send(type, *args)
391
+ end
392
+ end
393
+ end
394
+
395
+ if dependencies.pass?
396
+ puts "You appear to have all necessary dependencies installed"
397
+ else
398
+ puts "The following dependencies failed. Please check them and try again:"
399
+ dependencies.reject { |d| d.pass? }.each do |d|
400
+ puts "--> #{d.message}"
401
+ end
402
+ abort
403
+ end
404
+ end
405
+
406
+ desc <<-DESC
407
+ Deploys and starts a `cold' application. This is useful if you have not \
408
+ deployed your application before, or if your application is (for some \
409
+ other reason) not currently running. It will deploy the code, run any \
410
+ pending migrations, and then instead of invoking `deploy:restart', it will \
411
+ invoke `deploy:start' to fire up the application servers.
412
+ DESC
413
+ task :cold do
414
+ update
415
+ end
416
+
417
+ namespace :pending do
418
+ desc <<-DESC
419
+ Displays the `diff' since your last deploy. This is useful if you want \
420
+ to examine what changes are about to be deployed. Note that this might \
421
+ not be supported on all SCM's.
422
+ DESC
423
+ task :diff, :except => { :no_release => true } do
424
+ system(source.local.diff(current_revision))
425
+ end
426
+
427
+ desc <<-DESC
428
+ Displays the commits since your last deploy. This is good for a summary \
429
+ of the changes that have occurred since the last deploy. Note that this \
430
+ might not be supported on all SCM's.
431
+ DESC
432
+ task :default, :except => { :no_release => true } do
433
+ from = source.next_revision(current_revision)
434
+ system(source.local.log(from))
435
+ end
436
+ end
437
+
438
+ end