capistrano-ash 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/ash/base.rb +46 -20
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.18
1
+ 0.0.19
data/lib/ash/base.rb CHANGED
@@ -30,36 +30,41 @@ configuration.load do
30
30
  # Default variables
31
31
  # --------------------------------------------
32
32
  # SSH
33
- set :user, proc{text_prompt("SSH username: ")}
34
- set :password, proc{Capistrano::CLI.password_prompt("SSH password for '#{user}':")}
33
+ set :user, proc{text_prompt("SSH username: ")}
34
+ set :password, proc{Capistrano::CLI.password_prompt("SSH password for '#{user}':")}
35
35
 
36
36
  # Database
37
- set :dbuser, proc{text_prompt("Database username: ")}
38
- set :dbpass, proc{Capistrano::CLI.password_prompt("Database password for '#{dbuser}':")}
39
- set :dbname, proc{text_prompt("Database name: ")}
37
+ set :dbuser, proc{text_prompt("Database username: ")}
38
+ set :dbpass, proc{Capistrano::CLI.password_prompt("Database password for '#{dbuser}':")}
39
+ set :dbname, proc{text_prompt("Database name: ")}
40
40
 
41
41
  # Source Control
42
- set :group_writable, false
43
- set :use_sudo, false
44
- set :scm, :subversion
45
- set :scm_verbose, true
46
- set :scm_username, proc{text_prompt("Subversion username: ")}
47
- set :scm_password, proc{Capistrano::CLI.password_prompt("Subversion password for '#{scm_username}': ")}
48
- set :keep_releases, 3
49
- set :deploy_via, :remote_cache
50
- set :copy_strategy, :checkout
51
- set :copy_compression, :bz2
52
- set :copy_exclude, [".svn", ".DS_Store", "*.sample", "LICENSE*", "Capfile",
42
+ set :group_writable, false
43
+ set :use_sudo, false
44
+ set :scm, :subversion
45
+ set :scm_verbose, true
46
+ set :scm_username, proc{text_prompt("Subversion username: ")}
47
+ set :scm_password, proc{Capistrano::CLI.password_prompt("Subversion password for '#{scm_username}': ")}
48
+ set :keep_releases, 3
49
+ set :deploy_via, :remote_cache
50
+ set :copy_strategy, :checkout
51
+ set :copy_compression, :bz2
52
+ set :copy_exclude, [".svn", ".DS_Store", "*.sample", "LICENSE*", "Capfile",
53
53
  "config", "*.rb", "*.sql", "nbproject", "_template"]
54
+
54
55
  # phpMyAdmin version
55
- set :pma_version, "3.3.8"
56
+ set :pma_version, "3.3.8"
56
57
 
57
58
  # Backups Path
58
- _cset(:backups_path) { File.join(deploy_to, "backups") }
59
+ _cset(:backups_path) { File.join(deploy_to, "backups") }
60
+ _cset(:backups) { capture("ls -x #{backups_path}", :except => { :no_release => true }).split.sort }
59
61
 
60
62
  # Define which files or directories you want to exclude from being backed up
61
- _cset(:backup_exclude) { [] }
62
- set :exclude_string, ''
63
+ _cset(:backup_exclude) { [] }
64
+ set :exclude_string, ''
65
+
66
+ # Define the default number of backups to keep
67
+ set :keep_backups, 10
63
68
 
64
69
  # show password requests on windows
65
70
  # (http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1)
@@ -189,6 +194,27 @@ configuration.load do
189
194
  ch.send_data "#{dbpass}\n" if out =~ /^Enter password:/
190
195
  end
191
196
  end
197
+
198
+ desc <<-DESC
199
+ Clean up old backups. By default, the last 10 backups are kept on each \
200
+ server (though you can change this with the keep_backups variable). All \
201
+ other backups are removed from the servers. By default, this \
202
+ will use sudo to clean up the old backups, but if sudo is not available \
203
+ for your environment, set the :use_sudo variable to false instead.
204
+ DESC
205
+ task :cleanup, :except => { :no_release => true } do
206
+ count = fetch(:keep_backups, 10).to_i
207
+ if count >= backups.length
208
+ logger.important "no old backups to clean up"
209
+ else
210
+ logger.info "keeping #{count} of #{backups.length} backups"
211
+
212
+ archives = (backups - backups.last(count)).map { |backup|
213
+ File.join(backups_path, backup) }.join(" ")
214
+
215
+ try_sudo "rm -rf #{archives}"
216
+ end
217
+ end
192
218
  end
193
219
 
194
220
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 18
9
- version: 0.0.18
8
+ - 19
9
+ version: 0.0.19
10
10
  platform: ruby
11
11
  authors:
12
12
  - August Ash
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-29 00:00:00 -06:00
17
+ date: 2011-01-09 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies: []
20
20