Skip to content

Commit

Permalink
part 2, rename switchtower -> capistrano
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@3786 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Mar 6, 2006
1 parent 88a09bb commit 6efd009
Show file tree
Hide file tree
Showing 39 changed files with 59 additions and 57 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,5 +1,7 @@
*1.0.2* *SVN* *1.0.2* *SVN*


* Rename to capistrano

* Make the generated switchtower.rake file use rake namespaces, and include all default tasks * Make the generated switchtower.rake file use rake namespaces, and include all default tasks


* Look for config/deploy.rb and stasks file by default * Look for config/deploy.rb and stasks file by default
Expand Down
2 changes: 1 addition & 1 deletion MIT-LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2005 Jamis Buck Copyright (c) 2005,2006 Jamis Buck


Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
Expand Down
24 changes: 12 additions & 12 deletions README
@@ -1,35 +1,35 @@
= SwitchTower = Capistrano


SwitchTower is a utility and framework for executing commands in parallel on multiple remote machines, via SSH. It uses a simple DSL (borrowed in part from Rake, http://rake.rubyforge.org/) that allows you to define _tasks_, which may be applied to machines in certain roles. It also supports tunneling connections via some gateway machine to allow operations to be performed behind VPN's and firewalls. Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH. It uses a simple DSL (borrowed in part from Rake, http://rake.rubyforge.org/) that allows you to define _tasks_, which may be applied to machines in certain roles. It also supports tunneling connections via some gateway machine to allow operations to be performed behind VPN's and firewalls.


SwitchTower was originally designed to simplify and automate deployment of web applications to distributed environments, and so it comes with many tasks predefined for that ("update_code" and "deploy", for instance). Capistrano was originally designed to simplify and automate deployment of web applications to distributed environments, and so it comes with many tasks predefined for that ("update_code" and "deploy", for instance).


== Dependencies == Dependencies


SwitchTower depends upon the Net::SSH library by Jamis Buck (http://net-ssh.rubyforge.org). Net::SSH itself depends on the Needle library (http://needle.rubyforge.org), also by Jamis Buck. Capistrano depends upon the Net::SSH library by Jamis Buck (http://net-ssh.rubyforge.org). Net::SSH itself depends on the Needle library (http://needle.rubyforge.org), also by Jamis Buck.


== Assumptions == Assumptions


In keeping with Rails' "convention over configuration", SwitchTower makes several assumptions about how you will use it (most, if not all, of which may be explicitly overridden): In keeping with Rails' "convention over configuration", Capistrano makes several assumptions about how you will use it (most, if not all, of which may be explicitly overridden):


* You are writing web applications and want to use SwitchTower to deploy them. * You are writing web applications and want to use Capistrano to deploy them.
* You are using Ruby on Rails (http://www.rubyonrails.com) to build your apps. * You are using Ruby on Rails (http://www.rubyonrails.com) to build your apps.
* You are using Subversion (http://subversion.tigris.org/) to manage your source code. * You are using Subversion (http://subversion.tigris.org/) to manage your source code.
* You are running your apps using FastCGI, together with Rails' spinner/reaper utilities. * You are running your apps using FastCGI, together with Rails' spinner/reaper utilities.


As with the rest of Rails, if you can abide by these assumptions, you can use SwitchTower "out of the box". If any of these assumptions do not hold, you'll need to make some adjustments to your deployment recipe files. As with the rest of Rails, if you can abide by these assumptions, you can use Capistrano "out of the box". If any of these assumptions do not hold, you'll need to make some adjustments to your deployment recipe files.


== Usage == Usage


More documentation is always pending, but you'll want to see the user manual for detailed usage instructions. (The manual is online at http://manuals.rubyonrails.org/read/book/17). More documentation is always pending, but you'll want to see the user manual for detailed usage instructions. (The manual is online at http://manuals.rubyonrails.org/read/book/17).


In general, you'll use SwitchTower as follows: In general, you'll use Capistrano as follows:


* Create a deployment recipe ("deploy.rb") for your application. You can use the sample recipe in examples/sample.rb as a starting point. * Create a deployment recipe ("deploy.rb") for your application. You can use the sample recipe in examples/sample.rb as a starting point.
* Use the +switchtower+ script to execute your recipe (see below). * Use the +cap+ script to execute your recipe (see below).


Use the +switchtower+ script as follows: Use the +cap+ script as follows:


switchtower -r deploy -a someaction -vvv cap -vvv someaction


The <tt>-r</tt> switch specifies the recipe to use, and the <tt>-a</tt> switch specifies which action you want to execute. You can the <tt>-v</tt> switch multiple times (as shown) to increase the verbosity of the output. By default, the script will look for a file called one of <tt>config/deploy</tt>, <tt>config/deploy.rb</tt>, <tt>capistrano</tt>, or <tt>capistrano.rb</tt>. You can the <tt>-v</tt> switch multiple times (as shown) to increase the verbosity of the output. The +someaction+ text indicates which action to execute.
8 changes: 4 additions & 4 deletions Rakefile
Expand Up @@ -5,11 +5,11 @@ require 'rake/packagetask'
require 'rake/gempackagetask' require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher' require 'rake/contrib/rubyforgepublisher'


require "./lib/switchtower/version" require "./lib/capistrano/version"


PKG_NAME = "switchtower" PKG_NAME = "capistrano"
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_VERSION = SwitchTower::Version::STRING + PKG_BUILD PKG_VERSION = Capistrano::Version::STRING + PKG_BUILD
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"


desc "Default task" desc "Default task"
Expand All @@ -35,7 +35,7 @@ end
desc "Build the RDoc API documentation" desc "Build the RDoc API documentation"
Rake::RDocTask.new do |rdoc| Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = "doc" rdoc.rdoc_dir = "doc"
rdoc.title = "SwitchTower -- A framework for remote command execution" rdoc.title = "Capistrano -- A framework for remote command execution"
rdoc.options << '--line-numbers --inline-source --main README' rdoc.options << '--line-numbers --inline-source --main README'
rdoc.rdoc_files.include 'README' rdoc.rdoc_files.include 'README'
rdoc.rdoc_files.include 'lib/**/*.rb' rdoc.rdoc_files.include 'lib/**/*.rb'
Expand Down
4 changes: 2 additions & 2 deletions bin/switchtower → bin/cap
Expand Up @@ -6,6 +6,6 @@ rescue LoadError
# no rubygems to load, so we fail silently # no rubygems to load, so we fail silently
end end


require 'switchtower/cli' require 'capistrano/cli'


SwitchTower::CLI.execute! Capistrano::CLI.execute!
16 changes: 8 additions & 8 deletions switchtower.gemspec → capistrano.gemspec
@@ -1,29 +1,29 @@
require './lib/switchtower/version' require './lib/capistrano/version'


Gem::Specification.new do |s| Gem::Specification.new do |s|


s.name = 'switchtower' s.name = 'capistrano'
s.version = PKG_VERSION s.version = PKG_VERSION
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.summary = <<-DESC.strip.gsub(/\n/, " ") s.summary = <<-DESC.strip.gsub(/\n/, " ")
SwitchTower is a framework and utility for executing commands in parallel Capistrano is a framework and utility for executing commands in parallel
on multiple remote machines, via SSH. The primary goal is to simplify and on multiple remote machines, via SSH. The primary goal is to simplify and
automate the deployment of web applications. automate the deployment of web applications.
DESC DESC


s.files = Dir.glob("{bin,lib,examples,test}/**/*") s.files = Dir.glob("{bin,lib,examples,test}/**/*")
s.files.concat %w(README MIT-LICENSE ChangeLog) s.files.concat %w(README MIT-LICENSE ChangeLog)
s.require_path = 'lib' s.require_path = 'lib'
s.autorequire = 'switchtower' s.autorequire = 'capistrano'


s.bindir = "bin" s.bindir = "bin"
s.executables << "switchtower" s.executables << "cap"


s.add_dependency 'net-ssh', ">= #{SwitchTower::Version::SSH_REQUIRED.join(".")}" s.add_dependency 'net-ssh', ">= #{Capistrano::Version::SSH_REQUIRED.join(".")}"
s.add_dependency 'net-sftp', ">= #{SwitchTower::Version::SFTP_REQUIRED.join(".")}" s.add_dependency 'net-sftp', ">= #{Capistrano::Version::SFTP_REQUIRED.join(".")}"


s.author = "Jamis Buck" s.author = "Jamis Buck"
s.email = "jamis@37signals.com" s.email = "jamis@37signals.com"
s.homepage = "http://www.rubyonrails.com" s.homepage = "http://www.rubyonrails.org"


end end
1 change: 1 addition & 0 deletions lib/capistrano.rb
@@ -0,0 +1 @@
require 'capistrano/configuration'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion lib/switchtower.rb

This file was deleted.

16 changes: 8 additions & 8 deletions test/actor_test.rb
Expand Up @@ -2,9 +2,9 @@


require 'stringio' require 'stringio'
require 'test/unit' require 'test/unit'
require 'switchtower/actor' require 'capistrano/actor'
require 'switchtower/logger' require 'capistrano/logger'
require 'switchtower/configuration' require 'capistrano/configuration'


class ActorTest < Test::Unit::TestCase class ActorTest < Test::Unit::TestCase


Expand Down Expand Up @@ -44,7 +44,7 @@ def process!
end end
end end


class TestActor < SwitchTower::Actor class TestActor < Capistrano::Actor
attr_reader :factory attr_reader :factory


self.connection_factory = TestingConnectionFactory self.connection_factory = TestingConnectionFactory
Expand Down Expand Up @@ -80,7 +80,7 @@ def roles
end end


def logger def logger
@logger ||= SwitchTower::Logger.new(:output => StringIO.new) @logger ||= Capistrano::Logger.new(:output => StringIO.new)
end end
end end


Expand Down Expand Up @@ -267,7 +267,7 @@ def test_task_after_hook
end end


def test_uppercase_variables def test_uppercase_variables
config = SwitchTower::Configuration.new(TestActor) config = Capistrano::Configuration.new(TestActor)
config.set :HELLO, "world" config.set :HELLO, "world"
assert_equal "world", config.actor.instance_eval("HELLO") assert_equal "world", config.actor.instance_eval("HELLO")
config.set :HELLO, "test" config.set :HELLO, "test"
Expand All @@ -283,12 +283,12 @@ def test_connect_when_no_matching_servers
end end


def test_custom_extension def test_custom_extension
assert SwitchTower.plugin(:custom, CustomExtension) assert Capistrano.plugin(:custom, CustomExtension)
@actor.define_task :foo, :roles => :db do @actor.define_task :foo, :roles => :db do
custom.do_something_extra(1, 2, 3) custom.do_something_extra(1, 2, 3)
end end
assert_nothing_raised { @actor.foo } assert_nothing_raised { @actor.foo }
assert TestingCommand.invoked? assert TestingCommand.invoked?
assert SwitchTower.remove_plugin(:custom) assert Capistrano.remove_plugin(:custom)
end end
end end
8 changes: 4 additions & 4 deletions test/command_test.rb
Expand Up @@ -2,7 +2,7 @@


require 'stringio' require 'stringio'
require 'test/unit' require 'test/unit'
require 'switchtower/command' require 'capistrano/command'


class CommandTest < Test::Unit::TestCase class CommandTest < Test::Unit::TestCase
class MockSession class MockSession
Expand All @@ -24,19 +24,19 @@ def setup
end end


def test_command_executes_on_all_servers def test_command_executes_on_all_servers
command = SwitchTower::Command.new(%w(server1 server2 server3), command = Capistrano::Command.new(%w(server1 server2 server3),
"hello", nil, {}, @actor) "hello", nil, {}, @actor)
assert_equal %w(server1 server2 server3), @actor.sessions.keys.sort assert_equal %w(server1 server2 server3), @actor.sessions.keys.sort
end end


def test_command_with_newlines def test_command_with_newlines
command = SwitchTower::Command.new(%w(server1), "hello\nworld", nil, {}, command = Capistrano::Command.new(%w(server1), "hello\nworld", nil, {},
@actor) @actor)
assert_equal "hello\\\nworld", command.command assert_equal "hello\\\nworld", command.command
end end


def test_command_with_windows_newlines def test_command_with_windows_newlines
command = SwitchTower::Command.new(%w(server1), "hello\r\nworld", nil, {}, command = Capistrano::Command.new(%w(server1), "hello\r\nworld", nil, {},
@actor) @actor)
assert_equal "hello\\\nworld", command.command assert_equal "hello\\\nworld", command.command
end end
Expand Down
8 changes: 4 additions & 4 deletions test/configuration_test.rb
@@ -1,7 +1,7 @@
$:.unshift File.dirname(__FILE__) + "/../lib" $:.unshift File.dirname(__FILE__) + "/../lib"


require 'test/unit' require 'test/unit'
require 'switchtower/configuration' require 'capistrano/configuration'
require 'flexmock' require 'flexmock'


class ConfigurationTest < Test::Unit::TestCase class ConfigurationTest < Test::Unit::TestCase
Expand All @@ -25,7 +25,7 @@ def initialize(config)
end end


def setup def setup
@config = SwitchTower::Configuration.new(MockActor) @config = Capistrano::Configuration.new(MockActor)
@config.set :scm, MockSCM @config.set :scm, MockSCM
end end


Expand Down Expand Up @@ -210,12 +210,12 @@ def test_task_description


def test_set_scm_to_darcs def test_set_scm_to_darcs
@config.set :scm, :darcs @config.set :scm, :darcs
assert_equal "SwitchTower::SCM::Darcs", @config.source.class.name assert_equal "Capistrano::SCM::Darcs", @config.source.class.name
end end


def test_set_scm_to_subversion def test_set_scm_to_subversion
@config.set :scm, :subversion @config.set :scm, :subversion
assert_equal "SwitchTower::SCM::Subversion", @config.source.class.name assert_equal "Capistrano::SCM::Subversion", @config.source.class.name
end end


def test_get_proc_variable_sets_original_value_hash def test_get_proc_variable_sets_original_value_hash
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/custom.rb
@@ -1,3 +1,3 @@
SwitchTower.configuration(:must_exist).load do Capistrano.configuration(:must_exist).load do
set :gateway, "foo" set :gateway, "foo"
end end
4 changes: 2 additions & 2 deletions test/scm/cvs_test.rb
Expand Up @@ -2,10 +2,10 @@


require File.dirname(__FILE__) + "/../utils" require File.dirname(__FILE__) + "/../utils"
require 'test/unit' require 'test/unit'
require 'switchtower/scm/cvs' require 'capistrano/scm/cvs'


class ScmCvsTest < Test::Unit::TestCase class ScmCvsTest < Test::Unit::TestCase
class CvsTest < SwitchTower::SCM::Cvs class CvsTest < Capistrano::SCM::Cvs
attr_accessor :story attr_accessor :story
attr_reader :last_path attr_reader :last_path


Expand Down
6 changes: 3 additions & 3 deletions test/scm/subversion_test.rb
Expand Up @@ -2,10 +2,10 @@


require File.dirname(__FILE__) + "/../utils" require File.dirname(__FILE__) + "/../utils"
require 'test/unit' require 'test/unit'
require 'switchtower/scm/subversion' require 'capistrano/scm/subversion'


class ScmSubversionTest < Test::Unit::TestCase class ScmSubversionTest < Test::Unit::TestCase
class SubversionTest < SwitchTower::SCM::Subversion class SubversionTest < Capistrano::SCM::Subversion
attr_accessor :story attr_accessor :story
attr_reader :last_path attr_reader :last_path


Expand Down Expand Up @@ -61,7 +61,7 @@ def setup
------------------------------------------------------------------------ ------------------------------------------------------------------------
r1967 | minam | 2005-08-03 06:59:03 -0600 (Wed, 03 Aug 2005) | 2 lines r1967 | minam | 2005-08-03 06:59:03 -0600 (Wed, 03 Aug 2005) | 2 lines
Initial commit of the new switchtower utility Initial commit of the new capistrano utility
------------------------------------------------------------------------ ------------------------------------------------------------------------
MSG MSG
Expand Down
12 changes: 6 additions & 6 deletions test/ssh_test.rb
Expand Up @@ -2,7 +2,7 @@


require File.dirname(__FILE__) + "/utils" require File.dirname(__FILE__) + "/utils"
require 'test/unit' require 'test/unit'
require 'switchtower/ssh' require 'capistrano/ssh'


class SSHTest < Test::Unit::TestCase class SSHTest < Test::Unit::TestCase
class MockSSH class MockSSH
Expand Down Expand Up @@ -30,7 +30,7 @@ def setup


def test_publickey_auth_succeeds_default_port_no_block def test_publickey_auth_succeeds_default_port_no_block
Net.const_during(:SSH, MockSSH) do Net.const_during(:SSH, MockSSH) do
SwitchTower::SSH.connect('demo.server.i', @config) Capistrano::SSH.connect('demo.server.i', @config)
end end


assert_equal 1, MockSSH.invocations.length assert_equal 1, MockSSH.invocations.length
Expand All @@ -45,7 +45,7 @@ def test_publickey_auth_succeeds_default_port_no_block


def test_publickey_auth_succeeds_explicit_port_no_block def test_publickey_auth_succeeds_explicit_port_no_block
Net.const_during(:SSH, MockSSH) do Net.const_during(:SSH, MockSSH) do
SwitchTower::SSH.connect('demo.server.i', @config, 23) Capistrano::SSH.connect('demo.server.i', @config, 23)
end end


assert_equal 1, MockSSH.invocations.length assert_equal 1, MockSSH.invocations.length
Expand All @@ -55,7 +55,7 @@ def test_publickey_auth_succeeds_explicit_port_no_block


def test_publickey_auth_succeeds_with_block def test_publickey_auth_succeeds_with_block
Net.const_during(:SSH, MockSSH) do Net.const_during(:SSH, MockSSH) do
SwitchTower::SSH.connect('demo.server.i', @config) do |session| Capistrano::SSH.connect('demo.server.i', @config) do |session|
end end
end end


Expand All @@ -67,7 +67,7 @@ def test_publickey_auth_fails
MockSSH.story << Net::SSH::AuthenticationFailed MockSSH.story << Net::SSH::AuthenticationFailed


Net.const_during(:SSH, MockSSH) do Net.const_during(:SSH, MockSSH) do
SwitchTower::SSH.connect('demo.server.i', @config) Capistrano::SSH.connect('demo.server.i', @config)
end end


assert_equal 2, MockSSH.invocations.length assert_equal 2, MockSSH.invocations.length
Expand All @@ -87,7 +87,7 @@ def test_password_auth_fails


Net.const_during(:SSH, MockSSH) do Net.const_during(:SSH, MockSSH) do
assert_raises(Net::SSH::AuthenticationFailed) do assert_raises(Net::SSH::AuthenticationFailed) do
SwitchTower::SSH.connect('demo.server.i', @config) Capistrano::SSH.connect('demo.server.i', @config)
end end
end end


Expand Down

0 comments on commit 6efd009

Please sign in to comment.