obbistrano 1.1.76 → 1.1.77

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,54 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
2
 
3
+ #### Global helper methods ######
4
+
5
+ STDOUT.sync
6
+ $error = false
7
+ $pretty_errors_defined = false
8
+
9
+ # Be less verbose by default
10
+ logger.level = Capistrano::Logger::IMPORTANT
11
+
12
+ def pretty_print(msg)
13
+ if logger.level == Capistrano::Logger::IMPORTANT
14
+ pretty_errors
15
+ msg = msg.slice(0, 57)
16
+ msg << '.' * (60 - msg.size)
17
+ print msg
18
+ else
19
+ puts msg.green
20
+ end
21
+ end
22
+
23
+ def puts_ok
24
+ if logger.level == Capistrano::Logger::IMPORTANT && !$error
25
+ puts '✔'.green
26
+ end
27
+ $error = false
28
+ end
29
+
30
+ def pretty_errors
31
+ if !$pretty_errors_defined
32
+ $pretty_errors_defined = true
33
+
34
+ class << $stderr
35
+ @@firstLine = true
36
+ alias _write write
37
+
38
+ def write(s)
39
+ if @@firstLine
40
+ s = '✘' << "\n" << s
41
+ @@firstLine = false
42
+ end
43
+
44
+ _write(s.red)
45
+ $error = true
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+
3
52
  #### Performs the initial setup for tasks ####
4
53
  task :config_setup do
5
54
  set :root_pass, root rescue nil
@@ -14,7 +63,7 @@ Capistrano::Configuration.instance(:must_exist).load do
14
63
 
15
64
  desc "Sets up slicehost DNS for each of the servers specified with a role of web."
16
65
  task :setup do
17
- puts "*** You need to set a Slicehost API key in /etc/capistrano.conf to run this operation" if !defined? SLICEHOST_API_PASSWORD
66
+ pretty_print "*** You need to set a Slicehost API key in /etc/capistrano.conf to run this operation" if !defined? SLICEHOST_API_PASSWORD
18
67
  exit if !defined? SLICEHOST_API_PASSWORD
19
68
  get_slice_ip
20
69
  servers = find_servers :roles => :web
@@ -40,7 +89,7 @@ Capistrano::Configuration.instance(:must_exist).load do
40
89
 
41
90
  desc "Sets up slicehost DNS for Google Apps usage on each of the servers specified with a role of web."
42
91
  task :googleapps do
43
- puts "*** You need to set a Slicehost API key in /etc/capistrano.conf to run this operation" if !defined? SLICEHOST_API_PASSWORD
92
+ pretty_print "*** You need to set a Slicehost API key in /etc/capistrano.conf to run this operation" if !defined? SLICEHOST_API_PASSWORD
44
93
  exit if !defined? SLICEHOST_API_PASSWORD
45
94
  SLICEHOST_API_PASSWORD = "#{slicehost_api_key}"
46
95
  mx_records = <<-RECORD
@@ -74,7 +123,7 @@ Capistrano::Configuration.instance(:must_exist).load do
74
123
  namespace :github do
75
124
 
76
125
  task :init do
77
- puts "*** You need to specify a github login and token to run this operation" if !defined? "#{github_login}" || !defined? "#{github_token}"
126
+ pretty_print "*** You need to specify a github login and token to run this operation" if !defined? "#{github_login}" || !defined? "#{github_token}"
78
127
  exit if !defined? "#{github_login}" || !defined? "#{github_token}"
79
128
  end
80
129
 
@@ -289,7 +338,7 @@ Capistrano::Configuration.instance(:must_exist).load do
289
338
  command << tmp_cron_file
290
339
 
291
340
  if system(command.join(' '))
292
- puts "[write] crontab file updated"
341
+ pretty_print "[write] crontab file updated"
293
342
  exit
294
343
  else
295
344
  warn "[fail] couldn't write crontab"
@@ -406,7 +455,7 @@ Capistrano::Configuration.instance(:must_exist).load do
406
455
  run "cat /etc/debian_version"
407
456
  set :os_ver, "ubuntu"
408
457
  rescue
409
- puts "*** Operating System could not be detected or is not supported" if !defined? "#{os_ver}"
458
+ puts "*** Operating System could not be detected or is not supported" if !defined? "#{os_ver}".red
410
459
  exit if !defined? "#{os_ver}"
411
460
  end
412
461
  eval "#{os_ver}".testos
@@ -430,7 +479,7 @@ Capistrano::Configuration.instance(:must_exist).load do
430
479
  end
431
480
 
432
481
  task :needs_root do
433
- puts "*** This operation needs root access - Please set a root password inside your /etc/capistrano.conf file" if !defined? "#{root_pass}"
482
+ puts "*** This operation needs root access - Please set a root password inside your /etc/capistrano.conf file" if !defined? "#{root_pass}".red
434
483
  exit if !defined? "#{root_pass}"
435
484
  config_check
436
485
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{obbistrano}
5
- s.version = "1.1.76"
5
+ s.version = "1.1.77"
6
6
  s.authors = ["Ross Riley", "One Black Bear"]
7
7
  s.date = Time.now
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 76
9
- version: 1.1.76
8
+ - 77
9
+ version: 1.1.77
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ross Riley
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-03 00:00:00 +01:00
18
+ date: 2013-01-06 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency