capistrano_rsync_with_remote_cache 2.3.5 → 2.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Capistrano rsync_with_remote_cache
2
+
3
+ This gem provides a deployment strategy for Capistrano which combines `rsync` with a remote cache, allowing fast deployments from Subversion repositories behind firewalls.
4
+
5
+ ## Requirements
6
+
7
+ This gem requires Capistrano 2.0.0 or higher. Git support requires Capistrano 2.1.0 or higher.
8
+
9
+ This gem supports Subversion, Git, Mercurial and Bazaar. Only Subversion and Git have been extensively tested. This gem is unlikely to be supported for other SCM systems.
10
+
11
+ This gem requires `rsync` command line utilities on the local and remote hosts. It also requires either `svn`, `git`, `hg` or `bzr` on the local host, but not the remote host.
12
+
13
+ This gem is tested on Mac OS X and Linux. Windows is not tested or supported.
14
+
15
+ ## Using the strategy
16
+
17
+ To use this deployment strategy, add this line to your `deploy.rb` file:
18
+
19
+ set :deploy_via, :rsync_with_remote_cache
20
+
21
+ ## How it works
22
+
23
+ This strategy maintains two cache directories:
24
+
25
+ * The local cache directory is a checkout from the SCM repository. The local cache directory is specified with the `local_cache` variable in the configuration. If not specified, it will default to `.rsync_cache` in the same directory as the Capfile.
26
+ * The remote cache directory is an `rsync` copy of the local cache directory. The remote cache directory is specified with the `repository_cache` variable in the configuration (this name comes from the `remote_cache` strategy that ships with Capistrano, and has been maintained for compatibility.) If not specified, it will default to `shared/cached-copy` (again, for compatibility with remote_cache.)
27
+
28
+ Deployment happens in three major steps. First, the local cache directory is processed. There are three possibilities:
29
+
30
+ * If the local cache does not exist, it is created with a checkout of the revision to be deployed.
31
+ * If the local cache exists and matches the `:repository` variable, it is updated to the revision to be deployed.
32
+ * If the local cache exists and does not match the `:repository` variable, the local cache is purged and recreated with a checkout of the revision to be deployed.
33
+
34
+ Second, `rsync` runs on the local side to sync the remote cache to the local cache. When the `rsync` is complete, the remote cache should be an exact replica of the local cache.
35
+
36
+ Finally, a copy of the remote cache is made in the appropriate release directory. The end result is the same as if the code had been checked out directly on the remote server, as in the default strategy.
data/Rakefile CHANGED
@@ -12,9 +12,11 @@ begin
12
12
  gem.authors = ["Mark Cornick"]
13
13
  gem.rubyforge_project = "viget"
14
14
  gem.add_dependency 'capistrano', '>= 2.0'
15
+ gem.add_development_dependency "thoughtbot-shoulda"
16
+ gem.add_development_dependency "yard"
15
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
18
  end
17
-
19
+ Jeweler::GemcutterTasks.new
18
20
  Jeweler::RubyforgeTasks.new do |rubyforge|
19
21
  rubyforge.doc_task = "yardoc"
20
22
  end
@@ -43,6 +45,8 @@ rescue LoadError
43
45
  end
44
46
  end
45
47
 
48
+ task :test => :check_dependencies
49
+
46
50
  begin
47
51
  require 'reek/rake_task'
48
52
  Reek::RakeTask.new do |t|
@@ -72,9 +76,11 @@ task :default => :test
72
76
 
73
77
  begin
74
78
  require 'yard'
75
- YARD::Rake::YardocTask.new
79
+ YARD::Rake::YardocTask.new do |t|
80
+ t.options = ['--private']
81
+ end
76
82
  rescue LoadError
77
83
  task :yardoc do
78
- abort "Yard is not available. In order to run yardoc, you must: sudo gem install yard"
84
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
79
85
  end
80
86
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.5
1
+ 2.3.6
@@ -5,22 +5,22 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{capistrano_rsync_with_remote_cache}
8
- s.version = "2.3.5"
8
+ s.version = "2.3.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Cornick"]
12
- s.date = %q{2009-08-07}
12
+ s.date = %q{2009-09-08}
13
13
  s.description = %q{A deployment strategy for Capistrano 2.0 which combines rsync with a remote cache, allowing fast deployments from SCM servers behind firewalls.}
14
14
  s.email = %q{mark@viget.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
22
  "LICENSE",
23
- "README.rdoc",
23
+ "README.md",
24
24
  "Rakefile",
25
25
  "VERSION",
26
26
  "capistrano_rsync_with_remote_cache.gemspec",
@@ -46,10 +46,16 @@ Gem::Specification.new do |s|
46
46
 
47
47
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
48
  s.add_runtime_dependency(%q<capistrano>, [">= 2.0"])
49
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
50
+ s.add_development_dependency(%q<yard>, [">= 0"])
49
51
  else
50
52
  s.add_dependency(%q<capistrano>, [">= 2.0"])
53
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ s.add_dependency(%q<yard>, [">= 0"])
51
55
  end
52
56
  else
53
57
  s.add_dependency(%q<capistrano>, [">= 2.0"])
58
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
59
+ s.add_dependency(%q<yard>, [">= 0"])
54
60
  end
55
61
  end
@@ -24,7 +24,7 @@ module Capistrano
24
24
  # Step 2: Update the remote cache.
25
25
  logger.trace "copying local cache to remote"
26
26
  find_servers(:except => { :no_release => true }).each do |server|
27
- system("rsync #{rsync_options} #{local_cache}/ #{rsync_host(server)}:#{repository_cache}/")
27
+ system("rsync #{rsync_options} --rsh='ssh -p #{ssh_port}' #{local_cache}/ #{rsync_host(server)}:#{repository_cache}/")
28
28
  end
29
29
 
30
30
  # Step 3: Copy the remote cache into place.
@@ -61,6 +61,10 @@ module Capistrano
61
61
  configuration[:rsync_options] || "-az --delete"
62
62
  end
63
63
 
64
+ def ssh_port
65
+ ssh_options[:port] || 22
66
+ end
67
+
64
68
  # Returns the host used in the rsync command, prefixed with user@ if user is specified in Capfile.
65
69
  def rsync_host(server)
66
70
  if configuration[:user]
@@ -9,9 +9,8 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
9
9
  @rwrc.expects(:configuration).at_least_once.returns(hash)
10
10
  end
11
11
 
12
- def stub_detection_of_changed_local_cache(command, returned)
13
- File.expects(:directory?).with('.rsync_cache').returns(true)
14
- IO.expects(:popen).with(command).returns(returned)
12
+ def stub_ssh_options(hash)
13
+ @rwrc.expects(:ssh_options).at_least_once.returns(hash)
15
14
  end
16
15
 
17
16
  context 'RsyncWithRemoteCache' do
@@ -24,6 +23,7 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
24
23
 
25
24
  should 'deploy!' do
26
25
  stub_configuration(:deploy_to => 'deploy_to', :release_path => 'release_path', :scm => :subversion)
26
+ stub_ssh_options(:port => nil)
27
27
  @rwrc.stubs(:shared_path).returns('shared')
28
28
 
29
29
  # Step 1: Update the local cache.
@@ -35,7 +35,7 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
35
35
 
36
36
  # Step 2: Update the remote cache.
37
37
  server_stub = stub(:host => 'host')
38
- @rwrc.expects(:system).with("rsync -az --delete .rsync_cache/ host:shared/cached-copy/")
38
+ @rwrc.expects(:system).with("rsync -az --delete --rsh='ssh -p 22' .rsync_cache/ host:shared/cached-copy/")
39
39
  @rwrc.expects(:find_servers).returns([server_stub])
40
40
 
41
41
  # Step 3: Copy the remote cache into place.
@@ -96,6 +96,18 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
96
96
  end
97
97
  end
98
98
 
99
+ context 'ssh_port' do
100
+ should 'return specified port if present in configuration' do
101
+ stub_ssh_options(:port => 2222)
102
+ assert_equal 2222, @rwrc.send(:ssh_port)
103
+ end
104
+
105
+ should 'return default port if not present in configuration' do
106
+ stub_ssh_options(:port => nil)
107
+ assert_equal 22, @rwrc.send(:ssh_port)
108
+ end
109
+ end
110
+
99
111
  context 'rsync_host' do
100
112
  setup do
101
113
  @server_stub = stub(:host => 'host')
@@ -113,35 +125,18 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
113
125
  end
114
126
 
115
127
  context 'remove_cache_if_repo_changed' do
116
- should 'purge local cache if it detects subversion info has changed' do
117
- stub_configuration(:scm => :subversion, :repository => 'repository')
118
- stub_detection_of_changed_local_cache("cd .rsync_cache && svn info . | sed -n 's/URL: //p'", "URL: url\n")
119
- FileUtils.expects(:rm_rf).with('.rsync_cache')
120
- @rwrc.send(:remove_cache_if_repo_changed)
121
- end
122
-
123
- should 'purge local cache if it detects git info has changed' do
124
- stub_configuration(:scm => :git, :repository => 'repository')
125
- stub_detection_of_changed_local_cache("cd .rsync_cache && git config remote.origin.url", "beep\n")
126
- FileUtils.expects(:rm_rf).with('.rsync_cache')
127
- @rwrc.send(:remove_cache_if_repo_changed)
128
- end
129
-
130
- should 'purge local cache if it detects hg info has changed' do
131
- stub_configuration(:scm => :mercurial, :repository => 'repository')
132
- stub_detection_of_changed_local_cache("cd .rsync_cache && hg showconfig paths.default", "beep\n")
133
- FileUtils.expects(:rm_rf).with('.rsync_cache')
134
- @rwrc.send(:remove_cache_if_repo_changed)
135
- end
136
-
137
- should 'purge local cache if it detects bzr info has changed' do
138
- stub_configuration(:scm => :bzr, :repository => 'repository')
139
- stub_detection_of_changed_local_cache("cd .rsync_cache && bzr info | grep parent | sed 's/^.*parent branch: //'", "beep\n")
140
- FileUtils.expects(:rm_rf).with('.rsync_cache')
141
- @rwrc.send(:remove_cache_if_repo_changed)
142
- end
143
-
144
- should 'not attempt to purge local cache that does not exist' do
128
+ [:subversion, :git, :mercurial, :bzr].each do |scm|
129
+ should "purge local cache if it detects #{scm} info has changed" do
130
+ stub_configuration(:scm => scm, :repository => 'repository')
131
+ info_command = Capistrano::Deploy::Strategy::RsyncWithRemoteCache::INFO_COMMANDS[scm]
132
+ File.expects(:directory?).with('.rsync_cache').returns(true)
133
+ IO.expects(:popen).with("cd .rsync_cache && #{info_command}").returns('abc')
134
+ FileUtils.expects(:rm_rf).with('.rsync_cache')
135
+ @rwrc.send(:remove_cache_if_repo_changed)
136
+ end
137
+ end
138
+
139
+ should 'not attempt to purge local cache if it does not exist' do
145
140
  stub_configuration(:scm => :subversion, :repository => 'repository')
146
141
  File.expects(:directory?).with('.rsync_cache').returns(false)
147
142
  FileUtils.expects(:rm_rf).with('.rsync_cache').never
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_rsync_with_remote_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Cornick
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-07 00:00:00 -04:00
12
+ date: 2009-09-08 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,26 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "2.0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: thoughtbot-shoulda
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
25
45
  description: A deployment strategy for Capistrano 2.0 which combines rsync with a remote cache, allowing fast deployments from SCM servers behind firewalls.
26
46
  email: mark@viget.com
27
47
  executables: []
@@ -30,12 +50,12 @@ extensions: []
30
50
 
31
51
  extra_rdoc_files:
32
52
  - LICENSE
33
- - README.rdoc
53
+ - README.md
34
54
  files:
35
55
  - .document
36
56
  - .gitignore
37
57
  - LICENSE
38
- - README.rdoc
58
+ - README.md
39
59
  - Rakefile
40
60
  - VERSION
41
61
  - capistrano_rsync_with_remote_cache.gemspec
data/README.rdoc DELETED
@@ -1,36 +0,0 @@
1
- = Capistrano rsync_with_remote_cache
2
-
3
- This gem provides a deployment strategy for Capistrano which combines rsync with a remote cache, allowing fast deployments from Subversion repositories behind firewalls.
4
-
5
- == Requirements
6
-
7
- This gem requires Capistrano 2.0.0 or higher. Git support requires Capistrano 2.1.0 or higher.
8
-
9
- This gem supports Subversion, Git, Mercurial and Bazaar. Only Subversion and Git have been extensively tested. This gem is unlikely to be supported for other SCM systems.
10
-
11
- This gem requires <tt>rsync</tt> command line utilities on the local and remote hosts. It also requires either <tt>svn</tt>, <tt>git</tt>, <tt>hg</tt> or <hg>bzr</hg> on the local host, but not the remote host.
12
-
13
- This gem is tested on Mac OS X and Linux. Windows is not tested or supported.
14
-
15
- == Using the strategy
16
-
17
- To use this deployment strategy, add this line to your <tt>deploy.rb</tt> file:
18
-
19
- set :deploy_via, :rsync_with_remote_cache
20
-
21
- == How it works
22
-
23
- This strategy maintains two cache directories:
24
-
25
- * The local cache directory is a checkout from the SCM repository. The local cache directory is specified with the <tt>local_cache</tt> variable in the configuration. If not specified, it will default to <tt>.rsync_cache</tt> in the same directory as the Capfile.
26
- * The remote cache directory is an rsync copy of the local cache directory. The remote cache directory is specified with the <tt>repository_cache</tt> variable in the configuration (this name comes from the <tt>remote_cache</tt> strategy that ships with Capistrano, and has been maintained for compatibility.) If not specified, it will default to <tt>shared/cached-copy</tt> (again, for compatibility with remote_cache.)
27
-
28
- Deployment happens in three major steps. First, the local cache directory is processed. There are three possibilities:
29
-
30
- * If the local cache does not exist, it is created with a checkout of the revision to be deployed.
31
- * If the local cache exists and matches the <tt>:repository</tt> variable, it is updated to the revision to be deployed.
32
- * If the local cache exists and does not match the <tt>:repository</tt> variable, the local cache is purged and recreated with a checkout of the revision to be deployed.
33
-
34
- Second, rsync runs on the local side to sync the remote cache to the local cache. When the rsync is complete, the remote cache should be an exact replica of the local cache.
35
-
36
- Finally, a copy of the remote cache is made in the appropriate release directory. The end result is the same as if the code had been checked out directly on the remote server, as in the default strategy.