capistrano 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +89 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +674 -0
- data/README.md +226 -0
- data/Rakefile +5 -0
- data/bin/cap +2 -3
- data/bin/capify +7 -77
- data/capistrano-public_cert.pem +22 -0
- data/capistrano.gemspec +35 -0
- data/features/deploy.feature +52 -0
- data/features/installation.feature +16 -0
- data/features/remote_file_task.feature +14 -0
- data/features/step_definitions/assertions.rb +90 -0
- data/features/step_definitions/cap_commands.rb +8 -0
- data/features/step_definitions/setup.rb +25 -0
- data/features/support/env.rb +12 -0
- data/features/support/remote_command_helpers.rb +20 -0
- data/lib/Capfile +3 -0
- data/lib/capistrano/all.rb +16 -0
- data/lib/capistrano/application.rb +60 -0
- data/lib/capistrano/configuration/question.rb +42 -0
- data/lib/capistrano/configuration/server.rb +133 -0
- data/lib/capistrano/configuration/servers/role_filter.rb +86 -0
- data/lib/capistrano/configuration/servers.rb +53 -58
- data/lib/capistrano/configuration.rb +84 -30
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +13 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/dotfile.rb +3 -0
- data/lib/capistrano/dsl/env.rb +64 -0
- data/lib/capistrano/dsl/paths.rb +94 -0
- data/lib/capistrano/dsl/stages.rb +15 -0
- data/lib/capistrano/dsl/task_enhancements.rb +53 -0
- data/lib/capistrano/dsl.rb +48 -0
- data/lib/capistrano/git.rb +1 -0
- data/lib/capistrano/hg.rb +1 -0
- data/lib/capistrano/i18n.rb +34 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/setup.rb +21 -0
- data/lib/capistrano/tasks/console.rake +21 -0
- data/lib/capistrano/tasks/deploy.rake +204 -0
- data/lib/capistrano/tasks/framework.rake +67 -0
- data/lib/capistrano/tasks/git.rake +62 -0
- data/lib/capistrano/tasks/hg.rake +39 -0
- data/lib/capistrano/tasks/install.rake +39 -0
- data/lib/capistrano/templates/Capfile +26 -0
- data/lib/capistrano/templates/deploy.rb.erb +40 -0
- data/lib/capistrano/templates/stage.rb.erb +42 -0
- data/lib/capistrano/version.rb +1 -20
- data/lib/capistrano/version_validator.rb +37 -0
- data/lib/capistrano.rb +0 -2
- data/spec/integration/dsl_spec.rb +344 -0
- data/spec/integration_spec_helper.rb +7 -0
- data/spec/lib/capistrano/application_spec.rb +61 -0
- data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +249 -0
- data/spec/lib/capistrano/configuration/servers/role_filter_spec.rb +140 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +184 -0
- data/spec/lib/capistrano/configuration_spec.rb +101 -0
- data/spec/lib/capistrano/dsl/env_spec.rb +10 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
- data/spec/lib/capistrano/dsl_spec.rb +63 -0
- data/spec/lib/capistrano/version_validator_spec.rb +103 -0
- data/spec/lib/capistrano_spec.rb +8 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/.gitignore +1 -0
- data/spec/support/Vagrantfile +13 -0
- data/spec/support/matchers.rb +5 -0
- data/spec/support/tasks/database.cap +11 -0
- data/spec/support/test_app.rb +138 -0
- metadata +251 -179
- data/CHANGELOG +0 -512
- data/MIT-LICENSE +0 -20
- data/README +0 -43
- data/examples/sample.rb +0 -14
- data/lib/capistrano/callback.rb +0 -45
- data/lib/capistrano/cli/execute.rb +0 -82
- data/lib/capistrano/cli/help.rb +0 -102
- data/lib/capistrano/cli/help.txt +0 -53
- data/lib/capistrano/cli/options.rb +0 -183
- data/lib/capistrano/cli/ui.rb +0 -28
- data/lib/capistrano/cli.rb +0 -47
- data/lib/capistrano/command.rb +0 -161
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -35
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -134
- data/lib/capistrano/configuration/callbacks.rb +0 -148
- data/lib/capistrano/configuration/connections.rb +0 -159
- data/lib/capistrano/configuration/execution.rb +0 -126
- data/lib/capistrano/configuration/loading.rb +0 -198
- data/lib/capistrano/configuration/namespaces.rb +0 -196
- data/lib/capistrano/configuration/roles.rb +0 -51
- data/lib/capistrano/configuration/variables.rb +0 -127
- data/lib/capistrano/errors.rb +0 -15
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/gateway.rb +0 -131
- data/lib/capistrano/logger.rb +0 -59
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
- data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -46
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -96
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -192
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -151
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -85
- data/lib/capistrano/recipes/deploy/scm/git.rb +0 -191
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -129
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -126
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -114
- data/lib/capistrano/recipes/deploy/scm.rb +0 -19
- data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -64
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -144
- 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 -47
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
- data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/deploy.rb +0 -494
- data/lib/capistrano/recipes/standard.rb +0 -37
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/upgrade.rb +0 -33
- data/lib/capistrano/server_definition.rb +0 -51
- data/lib/capistrano/shell.rb +0 -256
- data/lib/capistrano/ssh.rb +0 -109
- data/lib/capistrano/task_definition.rb +0 -69
- data/lib/capistrano/upload.rb +0 -146
- data/test/cli/execute_test.rb +0 -132
- data/test/cli/help_test.rb +0 -139
- data/test/cli/options_test.rb +0 -226
- data/test/cli/ui_test.rb +0 -28
- data/test/cli_test.rb +0 -17
- data/test/command_test.rb +0 -309
- data/test/configuration/actions/file_transfer_test.rb +0 -40
- data/test/configuration/actions/inspect_test.rb +0 -62
- data/test/configuration/actions/invocation_test.rb +0 -202
- data/test/configuration/callbacks_test.rb +0 -206
- data/test/configuration/connections_test.rb +0 -288
- data/test/configuration/execution_test.rb +0 -159
- data/test/configuration/loading_test.rb +0 -127
- data/test/configuration/namespace_dsl_test.rb +0 -297
- data/test/configuration/roles_test.rb +0 -47
- data/test/configuration/servers_test.rb +0 -90
- data/test/configuration/variables_test.rb +0 -180
- data/test/configuration_test.rb +0 -81
- data/test/deploy/scm/accurev_test.rb +0 -23
- data/test/deploy/scm/base_test.rb +0 -55
- data/test/deploy/scm/git_test.rb +0 -112
- data/test/deploy/strategy/copy_test.rb +0 -147
- 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/gateway_test.rb +0 -167
- data/test/logger_test.rb +0 -123
- data/test/server_definition_test.rb +0 -108
- data/test/shell_test.rb +0 -64
- data/test/ssh_test.rb +0 -97
- data/test/task_definition_test.rb +0 -101
- data/test/upload_test.rb +0 -131
- data/test/utils.rb +0 -42
- data/test/version_test.rb +0 -24
data/test/upload_test.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/utils"
|
2
|
-
require 'capistrano/upload'
|
3
|
-
|
4
|
-
class UploadTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@mode = IO::WRONLY | IO::CREAT | IO::TRUNC
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_initialize_should_raise_error_if_data_is_missing
|
10
|
-
assert_raises(ArgumentError) do
|
11
|
-
Capistrano::Upload.new([], "test.txt", :foo => "bar")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_initialize_should_get_sftp_for_each_session
|
16
|
-
new_sftp = Proc.new do |state|
|
17
|
-
sftp = mock("sftp", :state => state, :open => nil)
|
18
|
-
sftp.expects(:connect) unless state == :open
|
19
|
-
sftp.stubs(:channel).returns({})
|
20
|
-
sftp
|
21
|
-
end
|
22
|
-
|
23
|
-
sessions = [mock("session", :xserver => server("a"), :sftp => new_sftp[:closed]),
|
24
|
-
mock("session", :xserver => server("b"), :sftp => new_sftp[:closed]),
|
25
|
-
mock("session", :xserver => server("c"), :sftp => new_sftp[:open])]
|
26
|
-
Capistrano::Upload.new(sessions, "test.txt", :data => "data")
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_self_process_should_instantiate_uploader_and_start_process
|
30
|
-
Capistrano::Upload.expects(:new).with([:s1, :s2], "test.txt", :data => "data").returns(mock(:process! => nil))
|
31
|
-
Capistrano::Upload.process([:s1, :s2], "test.txt", :data => "data")
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_process_when_sftp_open_fails_should_raise_error
|
35
|
-
sftp = mock_sftp
|
36
|
-
sftp.expects(:open).with("test.txt", @mode, 0664).yields(mock("status", :code => "bad status", :message => "bad status"), :file_handle)
|
37
|
-
session = mock("session", :sftp => sftp, :xserver => server("capistrano"))
|
38
|
-
upload = Capistrano::Upload.new([session], "test.txt", :data => "data", :logger => stub_everything)
|
39
|
-
assert_raises(Capistrano::UploadError) { upload.process! }
|
40
|
-
assert_equal 1, upload.failed
|
41
|
-
assert_equal 1, upload.completed
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_process_when_sftp_write_fails_should_raise_error
|
45
|
-
sftp = mock_sftp
|
46
|
-
sftp.expects(:open).with("test.txt", @mode, 0664).yields(mock("status1", :code => Net::SFTP::Session::FX_OK), :file_handle)
|
47
|
-
sftp.expects(:write).with(:file_handle, "data").yields(mock("status2", :code => "bad status", :message => "bad status"))
|
48
|
-
session = mock("session", :sftp => sftp, :xserver => server("capistrano"))
|
49
|
-
upload = Capistrano::Upload.new([session], "test.txt", :data => "data", :logger => stub_everything)
|
50
|
-
assert_raises(Capistrano::UploadError) { upload.process! }
|
51
|
-
assert_equal 1, upload.failed
|
52
|
-
assert_equal 1, upload.completed
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_upload_error_should_include_accessor_with_host_array
|
56
|
-
sftp = mock_sftp
|
57
|
-
sftp.expects(:open).with("test.txt", @mode, 0664).yields(mock("status1", :code => Net::SFTP::Session::FX_OK), :file_handle)
|
58
|
-
sftp.expects(:write).with(:file_handle, "data").yields(mock("status2", :code => "bad status", :message => "bad status"))
|
59
|
-
session = mock("session", :sftp => sftp, :xserver => server("capistrano"))
|
60
|
-
upload = Capistrano::Upload.new([session], "test.txt", :data => "data", :logger => stub_everything)
|
61
|
-
|
62
|
-
begin
|
63
|
-
upload.process!
|
64
|
-
flunk "expected an exception to be raised"
|
65
|
-
rescue Capistrano::UploadError => e
|
66
|
-
assert e.respond_to?(:hosts)
|
67
|
-
assert_equal %w(capistrano), e.hosts.map { |h| h.to_s }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_process_when_sftp_succeeds_should_raise_nothing
|
72
|
-
sftp = mock_sftp
|
73
|
-
sftp.expects(:open).with("test.txt", @mode, 0664).yields(mock("status1", :code => Net::SFTP::Session::FX_OK), :file_handle)
|
74
|
-
sftp.expects(:write).with(:file_handle, "data").yields(mock("status2", :code => Net::SFTP::Session::FX_OK))
|
75
|
-
sftp.expects(:close_handle).with(:file_handle).yields
|
76
|
-
session = mock("session", :sftp => sftp, :xserver => server("capistrano"))
|
77
|
-
upload = Capistrano::Upload.new([session], "test.txt", :data => "data", :logger => stub_everything)
|
78
|
-
assert_nothing_raised { upload.process! }
|
79
|
-
assert_equal 0, upload.failed
|
80
|
-
assert_equal 1, upload.completed
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_process_should_loop_while_running
|
84
|
-
con = mock("connection")
|
85
|
-
con.expects(:process).with(true).times(10)
|
86
|
-
channel = {}
|
87
|
-
channel.expects(:connection).returns(con).times(10)
|
88
|
-
sftp = mock("sftp", :state => :open, :open => nil)
|
89
|
-
sftp.stubs(:channel).returns(channel)
|
90
|
-
session = mock("session", :sftp => sftp, :xserver => server("capistrano"))
|
91
|
-
upload = Capistrano::Upload.new([session], "test.txt", :data => "data")
|
92
|
-
upload.expects(:running?).times(11).returns(*([true]*10 + [false]))
|
93
|
-
upload.process!
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_process_should_loop_but_not_process_done_channels
|
97
|
-
new_sftp = Proc.new do |done|
|
98
|
-
channel = {}
|
99
|
-
channel[:needs_done] = done
|
100
|
-
|
101
|
-
if !done
|
102
|
-
con = mock("connection")
|
103
|
-
con.expects(:process).with(true).times(10)
|
104
|
-
channel.expects(:connection).returns(con).times(10)
|
105
|
-
end
|
106
|
-
|
107
|
-
sftp = mock("sftp", :state => :open, :open => nil)
|
108
|
-
sftp.stubs(:channel).returns(channel)
|
109
|
-
sftp
|
110
|
-
end
|
111
|
-
|
112
|
-
sessions = [stub("session", :sftp => new_sftp[true], :xserver => server("capistrano")),
|
113
|
-
stub("session", :sftp => new_sftp[false], :xserver => server("cap2"))]
|
114
|
-
upload = Capistrano::Upload.new(sessions, "test.txt", :data => "data")
|
115
|
-
|
116
|
-
# make sure the sftp channels we wanted to be done, start as done
|
117
|
-
# (Upload.new marks each channel as not-done, so we have to do it here)
|
118
|
-
sessions.each { |s| s.sftp.channel[:done] = true if s.sftp.channel[:needs_done] }
|
119
|
-
upload.expects(:running?).times(11).returns(*([true]*10 + [false]))
|
120
|
-
upload.process!
|
121
|
-
end
|
122
|
-
|
123
|
-
private
|
124
|
-
|
125
|
-
def mock_sftp
|
126
|
-
sftp = mock("sftp", :state => :open)
|
127
|
-
sftp.stubs(:channel).returns(Hash.new)
|
128
|
-
yield sftp if block_given?
|
129
|
-
sftp
|
130
|
-
end
|
131
|
-
end
|
data/test/utils.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
unless defined?(TestExtensions)
|
2
|
-
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubygems'
|
6
|
-
gem 'mocha'
|
7
|
-
rescue LoadError
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'mocha'
|
12
|
-
require 'capistrano/server_definition'
|
13
|
-
|
14
|
-
module TestExtensions
|
15
|
-
def server(host, options={})
|
16
|
-
Capistrano::ServerDefinition.new(host, options)
|
17
|
-
end
|
18
|
-
|
19
|
-
def namespace(fqn=nil)
|
20
|
-
space = stub(:roles => {}, :fully_qualified_name => fqn, :default_task => nil)
|
21
|
-
yield(space) if block_given?
|
22
|
-
space
|
23
|
-
end
|
24
|
-
|
25
|
-
def role(space, name, *args)
|
26
|
-
opts = args.last.is_a?(Hash) ? args.pop : {}
|
27
|
-
space.roles[name] ||= []
|
28
|
-
space.roles[name].concat(args.map { |h| Capistrano::ServerDefinition.new(h, opts) })
|
29
|
-
end
|
30
|
-
|
31
|
-
def new_task(name, namespace=@namespace, options={}, &block)
|
32
|
-
block ||= Proc.new {}
|
33
|
-
task = Capistrano::TaskDefinition.new(name, namespace, options, &block)
|
34
|
-
assert_equal block, task.body
|
35
|
-
return task
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class Test::Unit::TestCase
|
40
|
-
include TestExtensions
|
41
|
-
end
|
42
|
-
end
|
data/test/version_test.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/utils"
|
2
|
-
require 'capistrano/version'
|
3
|
-
|
4
|
-
class VersionTest < Test::Unit::TestCase
|
5
|
-
def test_check_should_return_true_for_matching_parameters
|
6
|
-
assert Capistrano::Version.check([2], [2])
|
7
|
-
assert Capistrano::Version.check([2,1], [2,1])
|
8
|
-
assert Capistrano::Version.check([2,1,5], [2,1,5])
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_check_should_return_true_if_first_is_less_than_second
|
12
|
-
assert Capistrano::Version.check([2], [3])
|
13
|
-
assert Capistrano::Version.check([2], [2,1])
|
14
|
-
assert Capistrano::Version.check([2,1], [2,2])
|
15
|
-
assert Capistrano::Version.check([2,1], [2,1,1])
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_check_should_return_false_if_first_is_greater_than_second
|
19
|
-
assert !Capistrano::Version.check([3], [2])
|
20
|
-
assert !Capistrano::Version.check([3,1], [3])
|
21
|
-
assert !Capistrano::Version.check([3,2], [3,1])
|
22
|
-
assert !Capistrano::Version.check([3,2,1], [3,2])
|
23
|
-
end
|
24
|
-
end
|