forked from IceskYsl/vlad
/
vlad.rb
91 lines (78 loc) · 2.18 KB
/
vlad.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'rubygems'
require 'thread'
require 'rake_remote_task'
$TESTING ||= false
##
# Vlad the Deployer - Pragmatic application deployment automation, without mercy.
#
# Please read doco/getting_started.txt or http://rubyhitsquad.com/
#
# === Basic scenario:
#
# 1. rake vlad:setup (first time only)
# 2. rake vlad:update
# 3. rake vlad:migrate (optional)
# 4. rake vlad:start
module Vlad
##
# This is the version of Vlad you are running.
VERSION = '1.2.0'
##
# Base error class for all Vlad errors.
class Error < RuntimeError; end
##
# Raised when you have incorrectly configured Vlad.
class ConfigurationError < Error; end
##
# Raised when a remote command fails.
class CommandFailedError < Error; end
##
# Raised when an environment variable hasn't been set.
class FetchError < Error; end
##
# Loads tasks file +tasks_file+ and various recipe styles as a hash
# of category/style pairs. Recipes default to:
#
# :app => :mongrel
# :config => 'config/deploy.rb'
# :core => :core
# :scm => :subversion
# :web => :apache
#
# You can override individual values and/or set to nil to
# deactivate. :config will get loaded last to ensure that user
# variables override default values.
#
# And by all means, feel free to skip this entirely if it doesn't
# fit for you. All it does is a fancy-pants require. Require
# whatever files you need as you see fit straight from your
# Rakefile. YAY for simple and clean!
def self.load options = {}
options = {:config => options} if String === options
recipes = {
:app => :mongrel,
:config => 'config/deploy.rb',
:core => :core,
:scm => :subversion,
:web => :apache,
}.merge(options)
# be sure core comes first so base tasks aren't clobbered
if core = recipes.delete(:core)
require "vlad/#{core}"
end
recipes.each do |flavor, recipe|
next if recipe.nil? or flavor == :config
require "vlad/#{recipe}"
end
Kernel.load recipes[:config]
end
end
class String #:nodoc:
def cleanup
if ENV['FULL'] then
gsub(/\s+/, ' ').strip
else
self[/\A.*?\./]
end
end
end