capistrano 2.15.11 → 3.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +17 -8
- data/Gemfile +1 -12
- data/LICENSE.txt +18 -0
- data/README.md +65 -68
- data/Rakefile +4 -10
- data/bin/cap +2 -3
- data/bin/capify +7 -91
- data/capistrano.gemspec +20 -34
- data/lib/Capfile +2 -0
- data/lib/capistrano/application.rb +28 -0
- data/lib/capistrano/bundler.rb +1 -0
- data/lib/capistrano/configuration/question.rb +42 -0
- data/lib/capistrano/configuration/server.rb +24 -0
- data/lib/capistrano/configuration/servers.rb +43 -95
- data/lib/capistrano/configuration.rb +81 -44
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +11 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/dotfile.rb +3 -0
- data/lib/capistrano/dsl/env.rb +57 -0
- data/lib/capistrano/dsl/paths.rb +74 -0
- data/lib/capistrano/dsl/stages.rb +15 -0
- data/lib/capistrano/dsl/task_enhancements.rb +15 -0
- data/lib/capistrano/dsl.rb +38 -0
- data/lib/capistrano/git.rb +1 -0
- data/lib/capistrano/i18n.rb +33 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/setup.rb +17 -0
- data/lib/capistrano/tasks/bundler.rake +13 -0
- data/lib/capistrano/tasks/console.rake +21 -0
- data/lib/capistrano/tasks/deploy.rake +153 -0
- data/lib/capistrano/tasks/framework.rake +45 -0
- data/lib/capistrano/tasks/git.rake +65 -0
- data/lib/capistrano/tasks/install.rake +39 -0
- data/lib/capistrano/templates/Capfile +43 -0
- data/lib/capistrano/templates/deploy.rb.erb +17 -0
- data/lib/capistrano/templates/stage.rb.erb +20 -0
- data/lib/capistrano/version.rb +1 -11
- data/lib/capistrano.rb +9 -3
- data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +48 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +79 -0
- data/spec/lib/capistrano/configuration_spec.rb +80 -0
- data/spec/lib/capistrano/dsl/env_spec.rb +83 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
- data/spec/lib/capistrano/dsl_spec.rb +51 -0
- data/spec/lib/capistrano_spec.rb +8 -0
- data/spec/spec_helper.rb +14 -0
- metadata +89 -215
- data/.travis.yml +0 -9
- data/CHANGELOG +0 -1203
- data/lib/capistrano/callback.rb +0 -45
- data/lib/capistrano/cli/execute.rb +0 -85
- data/lib/capistrano/cli/help.rb +0 -125
- data/lib/capistrano/cli/help.txt +0 -81
- data/lib/capistrano/cli/options.rb +0 -243
- data/lib/capistrano/cli/ui.rb +0 -40
- data/lib/capistrano/cli.rb +0 -47
- data/lib/capistrano/command.rb +0 -303
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -50
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -329
- data/lib/capistrano/configuration/alias_task.rb +0 -26
- data/lib/capistrano/configuration/callbacks.rb +0 -147
- data/lib/capistrano/configuration/connections.rb +0 -237
- data/lib/capistrano/configuration/execution.rb +0 -142
- data/lib/capistrano/configuration/loading.rb +0 -205
- data/lib/capistrano/configuration/log_formatters.rb +0 -75
- data/lib/capistrano/configuration/namespaces.rb +0 -223
- data/lib/capistrano/configuration/roles.rb +0 -83
- data/lib/capistrano/configuration/variables.rb +0 -127
- data/lib/capistrano/errors.rb +0 -19
- data/lib/capistrano/ext/multistage.rb +0 -67
- data/lib/capistrano/ext/string.rb +0 -5
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +0 -8
- data/lib/capistrano/logger.rb +0 -166
- data/lib/capistrano/processable.rb +0 -55
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/assets.rb +0 -202
- data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
- data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -117
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -200
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
- data/lib/capistrano/recipes/deploy/scm/git.rb +0 -299
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
- data/lib/capistrano/recipes/deploy/scm/none.rb +0 -55
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -152
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
- data/lib/capistrano/recipes/deploy/scm.rb +0 -19
- data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -92
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -338
- data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
- data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +0 -21
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -20
- data/lib/capistrano/recipes/deploy.rb +0 -625
- data/lib/capistrano/recipes/standard.rb +0 -37
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/role.rb +0 -102
- data/lib/capistrano/server_definition.rb +0 -56
- data/lib/capistrano/shell.rb +0 -265
- data/lib/capistrano/ssh.rb +0 -95
- data/lib/capistrano/task_definition.rb +0 -77
- data/lib/capistrano/transfer.rb +0 -218
- data/test/cli/execute_test.rb +0 -132
- data/test/cli/help_test.rb +0 -165
- data/test/cli/options_test.rb +0 -329
- data/test/cli/ui_test.rb +0 -28
- data/test/cli_test.rb +0 -17
- data/test/command_test.rb +0 -322
- data/test/configuration/actions/file_transfer_test.rb +0 -61
- data/test/configuration/actions/inspect_test.rb +0 -76
- data/test/configuration/actions/invocation_test.rb +0 -306
- data/test/configuration/alias_task_test.rb +0 -118
- data/test/configuration/callbacks_test.rb +0 -201
- data/test/configuration/connections_test.rb +0 -439
- data/test/configuration/execution_test.rb +0 -175
- data/test/configuration/loading_test.rb +0 -148
- data/test/configuration/namespace_dsl_test.rb +0 -332
- data/test/configuration/roles_test.rb +0 -157
- data/test/configuration/servers_test.rb +0 -183
- data/test/configuration/variables_test.rb +0 -190
- data/test/configuration_test.rb +0 -77
- data/test/deploy/local_dependency_test.rb +0 -76
- data/test/deploy/remote_dependency_test.rb +0 -146
- data/test/deploy/scm/accurev_test.rb +0 -23
- data/test/deploy/scm/base_test.rb +0 -55
- data/test/deploy/scm/bzr_test.rb +0 -51
- data/test/deploy/scm/darcs_test.rb +0 -37
- data/test/deploy/scm/git_test.rb +0 -274
- data/test/deploy/scm/mercurial_test.rb +0 -134
- data/test/deploy/scm/none_test.rb +0 -35
- data/test/deploy/scm/perforce_test.rb +0 -23
- data/test/deploy/scm/subversion_test.rb +0 -68
- data/test/deploy/strategy/copy_test.rb +0 -360
- data/test/extensions_test.rb +0 -69
- data/test/fixtures/cli_integration.rb +0 -5
- data/test/fixtures/config.rb +0 -5
- data/test/fixtures/custom.rb +0 -3
- data/test/logger_formatting_test.rb +0 -149
- data/test/logger_test.rb +0 -134
- data/test/recipes_test.rb +0 -25
- data/test/role_test.rb +0 -11
- data/test/server_definition_test.rb +0 -121
- data/test/shell_test.rb +0 -96
- data/test/ssh_test.rb +0 -113
- data/test/task_definition_test.rb +0 -117
- data/test/transfer_test.rb +0 -168
- data/test/utils.rb +0 -37
- data/test/version_test.rb +0 -11
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
require 'capistrano/task_definition'
|
|
2
|
-
|
|
3
|
-
module Capistrano
|
|
4
|
-
class Configuration
|
|
5
|
-
module Namespaces
|
|
6
|
-
DEFAULT_TASK = :default
|
|
7
|
-
|
|
8
|
-
def self.included(base) #:nodoc:
|
|
9
|
-
base.send :alias_method, :initialize_without_namespaces, :initialize
|
|
10
|
-
base.send :alias_method, :initialize, :initialize_with_namespaces
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# The name of this namespace. Defaults to +nil+ for the top-level
|
|
14
|
-
# namespace.
|
|
15
|
-
attr_reader :name
|
|
16
|
-
|
|
17
|
-
# The parent namespace of this namespace. Returns +nil+ for the top-level
|
|
18
|
-
# namespace.
|
|
19
|
-
attr_reader :parent
|
|
20
|
-
|
|
21
|
-
# The hash of tasks defined for this namespace.
|
|
22
|
-
attr_reader :tasks
|
|
23
|
-
|
|
24
|
-
# The hash of namespaces defined for this namespace.
|
|
25
|
-
attr_reader :namespaces
|
|
26
|
-
|
|
27
|
-
def initialize_with_namespaces(*args) #:nodoc:
|
|
28
|
-
@name = @parent = nil
|
|
29
|
-
initialize_without_namespaces(*args)
|
|
30
|
-
@tasks = {}
|
|
31
|
-
@namespaces = {}
|
|
32
|
-
end
|
|
33
|
-
private :initialize_with_namespaces
|
|
34
|
-
|
|
35
|
-
# Returns the top-level namespace (the one with no parent).
|
|
36
|
-
def top
|
|
37
|
-
return parent.top if parent
|
|
38
|
-
return self
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Returns the fully-qualified name of this namespace, or nil if the
|
|
42
|
-
# namespace is at the top-level.
|
|
43
|
-
def fully_qualified_name
|
|
44
|
-
return nil if name.nil?
|
|
45
|
-
[parent.fully_qualified_name, name].compact.join(":")
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Describe the next task to be defined. The given text will be attached to
|
|
49
|
-
# the next task that is defined and used as its description.
|
|
50
|
-
def desc(text)
|
|
51
|
-
@next_description = text
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Returns the value set by the last, pending "desc" call. If +reset+ is
|
|
55
|
-
# not false, the value will be reset immediately afterwards.
|
|
56
|
-
def next_description(reset=false)
|
|
57
|
-
@next_description
|
|
58
|
-
ensure
|
|
59
|
-
@next_description = nil if reset
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Open a namespace in which to define new tasks. If the namespace was
|
|
63
|
-
# defined previously, it will be reopened, otherwise a new namespace
|
|
64
|
-
# will be created for the given name.
|
|
65
|
-
def namespace(name, &block)
|
|
66
|
-
name = name.to_sym
|
|
67
|
-
raise ArgumentError, "expected a block" unless block_given?
|
|
68
|
-
|
|
69
|
-
namespace_already_defined = namespaces.key?(name)
|
|
70
|
-
if all_methods.any? { |m| m.to_sym == name } && !namespace_already_defined
|
|
71
|
-
thing = tasks.key?(name) ? "task" : "method"
|
|
72
|
-
raise ArgumentError, "defining a namespace named `#{name}' would shadow an existing #{thing} with that name"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
namespaces[name] ||= Namespace.new(name, self)
|
|
76
|
-
namespaces[name].instance_eval(&block)
|
|
77
|
-
|
|
78
|
-
# make sure any open description gets terminated
|
|
79
|
-
namespaces[name].desc(nil)
|
|
80
|
-
|
|
81
|
-
if !namespace_already_defined
|
|
82
|
-
metaclass = class << self; self; end
|
|
83
|
-
metaclass.send(:define_method, name) { namespaces[name] }
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Describe a new task. If a description is active (see #desc), it is added
|
|
88
|
-
# to the options under the <tt>:desc</tt> key. The new task is added to
|
|
89
|
-
# the namespace.
|
|
90
|
-
def task(name, options={}, &block)
|
|
91
|
-
name = name.to_sym
|
|
92
|
-
raise ArgumentError, "expected a block" unless block_given?
|
|
93
|
-
|
|
94
|
-
task_already_defined = tasks.key?(name)
|
|
95
|
-
if all_methods.any? { |m| m.to_sym == name } && !task_already_defined
|
|
96
|
-
thing = namespaces.key?(name) ? "namespace" : "method"
|
|
97
|
-
raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name"
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
task = TaskDefinition.new(name, self, {:desc => next_description(:reset)}.merge(options), &block)
|
|
102
|
-
|
|
103
|
-
define_task(task)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def define_task(task)
|
|
107
|
-
tasks[task.name] = task
|
|
108
|
-
|
|
109
|
-
metaclass = class << self; self; end
|
|
110
|
-
metaclass.send(:define_method, task.name) { execute_task(tasks[task.name]) }
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# Find the task with the given name, where name is the fully-qualified
|
|
114
|
-
# name of the task. This will search into the namespaces and return
|
|
115
|
-
# the referenced task, or nil if no such task can be found. If the name
|
|
116
|
-
# refers to a namespace, the task in that namespace named "default"
|
|
117
|
-
# will be returned instead, if one exists.
|
|
118
|
-
def find_task(name)
|
|
119
|
-
parts = name.to_s.split(/:/)
|
|
120
|
-
tail = parts.pop.to_sym
|
|
121
|
-
|
|
122
|
-
ns = self
|
|
123
|
-
until parts.empty?
|
|
124
|
-
next_part = parts.shift
|
|
125
|
-
ns = next_part.empty? ? nil : ns.namespaces[next_part.to_sym]
|
|
126
|
-
return nil if ns.nil?
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
if ns.namespaces.key?(tail)
|
|
130
|
-
ns = ns.namespaces[tail]
|
|
131
|
-
tail = DEFAULT_TASK
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
ns.tasks[tail]
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Given a task name, this will search the current namespace, and all
|
|
138
|
-
# parent namespaces, looking for a task that matches the name, exactly.
|
|
139
|
-
# It returns the task, if found, or nil, if not.
|
|
140
|
-
def search_task(name)
|
|
141
|
-
name = name.to_sym
|
|
142
|
-
ns = self
|
|
143
|
-
|
|
144
|
-
until ns.nil?
|
|
145
|
-
return ns.tasks[name] if ns.tasks.key?(name)
|
|
146
|
-
ns = ns.parent
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
return nil
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# Returns the default task for this namespace. This will be +nil+ if
|
|
153
|
-
# the namespace is at the top-level, and will otherwise return the
|
|
154
|
-
# task named "default". If no such task exists, +nil+ will be returned.
|
|
155
|
-
def default_task
|
|
156
|
-
return nil if parent.nil?
|
|
157
|
-
return tasks[DEFAULT_TASK]
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# Returns the tasks in this namespace as an array of TaskDefinition
|
|
161
|
-
# objects. If a non-false parameter is given, all tasks in all
|
|
162
|
-
# namespaces under this namespace will be returned as well.
|
|
163
|
-
def task_list(all=false)
|
|
164
|
-
list = tasks.values
|
|
165
|
-
namespaces.each { |name,space| list.concat(space.task_list(:all)) } if all
|
|
166
|
-
list
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
private
|
|
170
|
-
|
|
171
|
-
def all_methods
|
|
172
|
-
public_methods.concat(protected_methods).concat(private_methods)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
class Namespace
|
|
176
|
-
def initialize(name, parent)
|
|
177
|
-
@parent = parent
|
|
178
|
-
@name = name
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def role(*args)
|
|
182
|
-
raise NotImplementedError, "roles cannot be defined in a namespace"
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def respond_to?(sym, include_priv=false)
|
|
186
|
-
super || parent.respond_to?(sym, include_priv)
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
def method_missing(sym, *args, &block)
|
|
190
|
-
if parent.respond_to?(sym)
|
|
191
|
-
parent.send(sym, *args, &block)
|
|
192
|
-
else
|
|
193
|
-
super
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
include Capistrano::Configuration::AliasTask
|
|
198
|
-
include Capistrano::Configuration::Namespaces
|
|
199
|
-
undef :desc, :next_description
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
module Kernel
|
|
206
|
-
class << self
|
|
207
|
-
alias_method :method_added_without_capistrano, :method_added
|
|
208
|
-
|
|
209
|
-
# Detect method additions to Kernel and remove them in the Namespace class
|
|
210
|
-
def method_added(name)
|
|
211
|
-
result = method_added_without_capistrano(name)
|
|
212
|
-
return result if self != Kernel
|
|
213
|
-
|
|
214
|
-
namespace = Capistrano::Configuration::Namespaces::Namespace
|
|
215
|
-
|
|
216
|
-
if namespace.method_defined?(name) && namespace.instance_method(name).owner == Kernel
|
|
217
|
-
namespace.send :undef_method, name
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
result
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
require 'capistrano/server_definition'
|
|
2
|
-
require 'capistrano/role'
|
|
3
|
-
|
|
4
|
-
module Capistrano
|
|
5
|
-
class Configuration
|
|
6
|
-
module Roles
|
|
7
|
-
def self.included(base) #:nodoc:
|
|
8
|
-
base.send :alias_method, :initialize_without_roles, :initialize
|
|
9
|
-
base.send :alias_method, :initialize, :initialize_with_roles
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# The hash of roles defined for this configuration. Each entry in the
|
|
13
|
-
# hash points to an array of server definitions that belong in that
|
|
14
|
-
# role.
|
|
15
|
-
attr_reader :roles
|
|
16
|
-
|
|
17
|
-
def initialize_with_roles(*args) #:nodoc:
|
|
18
|
-
initialize_without_roles(*args)
|
|
19
|
-
@roles = Hash.new { |h,k| h[k] = Role.new }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Define a new role and its associated servers. You must specify at least
|
|
23
|
-
# one host for each role. Also, you can specify additional information
|
|
24
|
-
# (in the form of a Hash) which can be used to more uniquely specify the
|
|
25
|
-
# subset of servers specified by this specific role definition.
|
|
26
|
-
#
|
|
27
|
-
# Usage:
|
|
28
|
-
#
|
|
29
|
-
# role :db, "db1.example.com", "db2.example.com"
|
|
30
|
-
# role :db, "master.example.com", :primary => true
|
|
31
|
-
# role :app, "app1.example.com", "app2.example.com"
|
|
32
|
-
#
|
|
33
|
-
# You can also encode the username and port number for each host in the
|
|
34
|
-
# server string, if needed:
|
|
35
|
-
#
|
|
36
|
-
# role :web, "www@web1.example.com"
|
|
37
|
-
# role :file, "files.example.com:4144"
|
|
38
|
-
# role :db, "admin@db3.example.com:1234"
|
|
39
|
-
#
|
|
40
|
-
# Lastly, username and port number may be passed as options, if that is
|
|
41
|
-
# preferred; note that the options apply to all servers defined in
|
|
42
|
-
# that call to "role":
|
|
43
|
-
#
|
|
44
|
-
# role :web, "web2", "web3", :user => "www", :port => 2345
|
|
45
|
-
def role(which, *args, &block)
|
|
46
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
47
|
-
which = which.to_sym
|
|
48
|
-
|
|
49
|
-
# The roles Hash is defined so that unrecognized keys always auto-initialize
|
|
50
|
-
# to a new Role instance (see the assignment in the initialize_with_roles method,
|
|
51
|
-
# above). However, we explicitly assign here so that role declarations will
|
|
52
|
-
# vivify the role object even if there are no server arguments. (Otherwise,
|
|
53
|
-
# role(:app) won't actually instantiate a Role object for :app.)
|
|
54
|
-
roles[which] ||= Role.new
|
|
55
|
-
|
|
56
|
-
roles[which].push(block, options) if block_given?
|
|
57
|
-
args.each { |host| roles[which] << ServerDefinition.new(host, options) }
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# An alternative way to associate servers with roles. If you have a server
|
|
61
|
-
# that participates in multiple roles, this can be a DRYer way to describe
|
|
62
|
-
# the relationships. Pass the host definition as the first parameter, and
|
|
63
|
-
# the roles as the remaining parameters:
|
|
64
|
-
#
|
|
65
|
-
# server "master.example.com", :web, :app
|
|
66
|
-
#
|
|
67
|
-
# Also, you can specify additional information
|
|
68
|
-
# (in the form of a Hash) which can be used to more uniquely specify the
|
|
69
|
-
# subset of servers specified by this specific definition:
|
|
70
|
-
#
|
|
71
|
-
# server "master.example.com", :db, :primary => true
|
|
72
|
-
def server(host, *roles)
|
|
73
|
-
options = roles.last.is_a?(Hash) ? roles.pop : {}
|
|
74
|
-
raise ArgumentError, "you must associate a server with at least one role" if roles.empty?
|
|
75
|
-
roles.each { |name| role(name, host, options) }
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def role_names_for_host(host)
|
|
79
|
-
roles.map {|role_name, role| role_name if role.include?(host) }.compact || []
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
require 'thread'
|
|
2
|
-
|
|
3
|
-
module Capistrano
|
|
4
|
-
class Configuration
|
|
5
|
-
module Variables
|
|
6
|
-
def self.included(base) #:nodoc:
|
|
7
|
-
%w(initialize respond_to? method_missing).each do |m|
|
|
8
|
-
base_name = m[/^\w+/]
|
|
9
|
-
punct = m[/\W+$/]
|
|
10
|
-
base.send :alias_method, "#{base_name}_without_variables#{punct}", m
|
|
11
|
-
base.send :alias_method, m, "#{base_name}_with_variables#{punct}"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# The hash of variables that have been defined in this configuration
|
|
16
|
-
# instance.
|
|
17
|
-
attr_reader :variables
|
|
18
|
-
|
|
19
|
-
# Set a variable to the given value.
|
|
20
|
-
def set(variable, *args, &block)
|
|
21
|
-
if variable.to_s !~ /^[_a-z]/
|
|
22
|
-
raise ArgumentError, "invalid variable `#{variable}' (variables must begin with an underscore, or a lower-case letter)"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
if !block_given? && args.empty? || block_given? && !args.empty?
|
|
26
|
-
raise ArgumentError, "you must specify exactly one of either a value or a block"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
if args.length > 1
|
|
30
|
-
raise ArgumentError, "wrong number of arguments (#{args.length} for 1)"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
value = args.empty? ? block : args.first
|
|
34
|
-
sym = variable.to_sym
|
|
35
|
-
protect(sym) { @variables[sym] = value }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
alias :[]= :set
|
|
39
|
-
|
|
40
|
-
# Removes any trace of the given variable.
|
|
41
|
-
def unset(variable)
|
|
42
|
-
sym = variable.to_sym
|
|
43
|
-
protect(sym) do
|
|
44
|
-
@original_procs.delete(sym)
|
|
45
|
-
@variables.delete(sym)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Returns true if the variable has been defined, and false otherwise.
|
|
50
|
-
def exists?(variable)
|
|
51
|
-
@variables.key?(variable.to_sym)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# If the variable was originally a proc value, it will be reset to it's
|
|
55
|
-
# original proc value. Otherwise, this method does nothing. It returns
|
|
56
|
-
# true if the variable was actually reset.
|
|
57
|
-
def reset!(variable)
|
|
58
|
-
sym = variable.to_sym
|
|
59
|
-
protect(sym) do
|
|
60
|
-
if @original_procs.key?(sym)
|
|
61
|
-
@variables[sym] = @original_procs.delete(sym)
|
|
62
|
-
true
|
|
63
|
-
else
|
|
64
|
-
false
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Access a named variable. If the value of the variable responds_to? :call,
|
|
70
|
-
# #call will be invoked (without parameters) and the return value cached
|
|
71
|
-
# and returned.
|
|
72
|
-
def fetch(variable, *args)
|
|
73
|
-
if !args.empty? && block_given?
|
|
74
|
-
raise ArgumentError, "you must specify either a default value or a block, but not both"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
sym = variable.to_sym
|
|
78
|
-
protect(sym) do
|
|
79
|
-
if !@variables.key?(sym)
|
|
80
|
-
return args.first unless args.empty?
|
|
81
|
-
return yield(variable) if block_given?
|
|
82
|
-
raise IndexError, "`#{variable}' not found"
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
if @variables[sym].respond_to?(:call)
|
|
86
|
-
@original_procs[sym] = @variables[sym]
|
|
87
|
-
@variables[sym] = @variables[sym].call
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
@variables[sym]
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def [](variable)
|
|
95
|
-
fetch(variable, nil)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def initialize_with_variables(*args) #:nodoc:
|
|
99
|
-
initialize_without_variables(*args)
|
|
100
|
-
@variables = {}
|
|
101
|
-
@original_procs = {}
|
|
102
|
-
@variable_locks = Hash.new { |h,k| h[k] = Mutex.new }
|
|
103
|
-
|
|
104
|
-
set :ssh_options, {}
|
|
105
|
-
set :logger, logger
|
|
106
|
-
end
|
|
107
|
-
private :initialize_with_variables
|
|
108
|
-
|
|
109
|
-
def protect(variable)
|
|
110
|
-
@variable_locks[variable.to_sym].synchronize { yield }
|
|
111
|
-
end
|
|
112
|
-
private :protect
|
|
113
|
-
|
|
114
|
-
def respond_to_with_variables?(sym, include_priv=false) #:nodoc:
|
|
115
|
-
@variables.has_key?(sym.to_sym) || respond_to_without_variables?(sym, include_priv)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def method_missing_with_variables(sym, *args, &block) #:nodoc:
|
|
119
|
-
if args.length == 0 && block.nil? && @variables.has_key?(sym)
|
|
120
|
-
self[sym]
|
|
121
|
-
else
|
|
122
|
-
method_missing_without_variables(sym, *args, &block)
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
data/lib/capistrano/errors.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Capistrano
|
|
2
|
-
|
|
3
|
-
Error = Class.new(RuntimeError)
|
|
4
|
-
|
|
5
|
-
CaptureError = Class.new(Capistrano::Error)
|
|
6
|
-
NoSuchTaskError = Class.new(Capistrano::Error)
|
|
7
|
-
NoMatchingServersError = Class.new(Capistrano::Error)
|
|
8
|
-
|
|
9
|
-
class RemoteError < Error
|
|
10
|
-
attr_accessor :hosts
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
ConnectionError = Class.new(Capistrano::RemoteError)
|
|
14
|
-
TransferError = Class.new(Capistrano::RemoteError)
|
|
15
|
-
CommandError = Class.new(Capistrano::RemoteError)
|
|
16
|
-
|
|
17
|
-
LocalArgumentError = Class.new(Capistrano::Error)
|
|
18
|
-
|
|
19
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
require 'fileutils'
|
|
2
|
-
|
|
3
|
-
unless Capistrano::Configuration.respond_to?(:instance)
|
|
4
|
-
abort "capistrano/ext/multistage requires Capistrano 2"
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
Capistrano::Configuration.instance.load do
|
|
8
|
-
location = fetch(:stage_dir, "config/deploy")
|
|
9
|
-
|
|
10
|
-
unless exists?(:stages)
|
|
11
|
-
set :stages, Dir["#{location}/*.rb"].map { |f| File.basename(f, ".rb") }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
stages.each do |name|
|
|
15
|
-
desc "Set the target stage to `#{name}'."
|
|
16
|
-
task(name) do
|
|
17
|
-
set :stage, name.to_sym
|
|
18
|
-
|
|
19
|
-
file = "#{location}/#{stage}"
|
|
20
|
-
load file if file_in_load_path?(file)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
on :load do
|
|
25
|
-
# The first non option argument
|
|
26
|
-
env = ARGV.detect { |a| a.to_s !~ /\A-/ && a.to_s !~ /=/ }
|
|
27
|
-
|
|
28
|
-
if stages.include?(env)
|
|
29
|
-
# Execute the specified stage so that recipes required in stage can contribute to task list
|
|
30
|
-
find_and_execute_task(env) if ARGV.any?{ |option| option =~ /-T|--tasks|-e|--explain/ }
|
|
31
|
-
else
|
|
32
|
-
# Execute the default stage so that recipes required in stage can contribute tasks
|
|
33
|
-
find_and_execute_task(default_stage) if exists?(:default_stage)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
namespace :multistage do
|
|
38
|
-
desc "[internal] Ensure that a stage has been selected."
|
|
39
|
-
task :ensure do
|
|
40
|
-
if !exists?(:stage)
|
|
41
|
-
if exists?(:default_stage)
|
|
42
|
-
logger.important "Defaulting to `#{default_stage}'"
|
|
43
|
-
find_and_execute_task(default_stage)
|
|
44
|
-
else
|
|
45
|
-
abort "No stage specified. Please specify one of: #{stages.join(', ')} (e.g. `cap #{stages.first} #{ARGV.last}')"
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
desc "Stub out the staging config files."
|
|
51
|
-
task :prepare do
|
|
52
|
-
FileUtils.mkdir_p(location)
|
|
53
|
-
stages.each do |name|
|
|
54
|
-
file = File.join(location, name + ".rb")
|
|
55
|
-
unless File.exist?(file)
|
|
56
|
-
File.open(file, "w") do |f|
|
|
57
|
-
f.puts "# #{name.upcase}-specific deployment configuration"
|
|
58
|
-
f.puts "# please put general deployment config in config/deploy.rb"
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
on :start, "multistage:ensure", :except => stages + ['multistage:prepare']
|
|
66
|
-
|
|
67
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
module Capistrano
|
|
2
|
-
class ExtensionProxy #:nodoc:
|
|
3
|
-
def initialize(config, mod)
|
|
4
|
-
@config = config
|
|
5
|
-
extend(mod)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def method_missing(sym, *args, &block)
|
|
9
|
-
@config.send(sym, *args, &block)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Holds the set of registered plugins, keyed by name (where the name is a
|
|
14
|
-
# symbol).
|
|
15
|
-
EXTENSIONS = {}
|
|
16
|
-
|
|
17
|
-
# Register the given module as a plugin with the given name. It will henceforth
|
|
18
|
-
# be available via a proxy object on Configuration instances, accessible by
|
|
19
|
-
# a method with the given name.
|
|
20
|
-
def self.plugin(name, mod)
|
|
21
|
-
name = name.to_sym
|
|
22
|
-
return false if EXTENSIONS.has_key?(name)
|
|
23
|
-
|
|
24
|
-
methods = Capistrano::Configuration.public_instance_methods +
|
|
25
|
-
Capistrano::Configuration.protected_instance_methods +
|
|
26
|
-
Capistrano::Configuration.private_instance_methods
|
|
27
|
-
|
|
28
|
-
if methods.any? { |m| m.to_sym == name }
|
|
29
|
-
raise Capistrano::Error, "registering a plugin named `#{name}' would shadow a method on Capistrano::Configuration with the same name"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
Capistrano::Configuration.class_eval <<-STR, __FILE__, __LINE__+1
|
|
33
|
-
def #{name}
|
|
34
|
-
@__#{name}_proxy ||= Capistrano::ExtensionProxy.new(self, Capistrano::EXTENSIONS[#{name.inspect}])
|
|
35
|
-
end
|
|
36
|
-
STR
|
|
37
|
-
|
|
38
|
-
EXTENSIONS[name] = mod
|
|
39
|
-
return true
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Unregister the plugin with the given name.
|
|
43
|
-
def self.remove_plugin(name)
|
|
44
|
-
name = name.to_sym
|
|
45
|
-
if EXTENSIONS.delete(name)
|
|
46
|
-
Capistrano::Configuration.send(:remove_method, name)
|
|
47
|
-
return true
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
return false
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def self.configuration(*args) #:nodoc:
|
|
54
|
-
warn "[DEPRECATION] Capistrano.configuration is deprecated. Use Capistrano::Configuration.instance instead"
|
|
55
|
-
Capistrano::Configuration.instance(*args)
|
|
56
|
-
end
|
|
57
|
-
end
|