vlad 1.0.0 → 1.1.0

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.
data/lib/vlad/perforce.rb CHANGED
@@ -1,18 +1,14 @@
1
1
  class Vlad::Perforce
2
2
 
3
- def self.reset
4
- set :p4cmd, "p4" unless respond_to? :p4cmd
5
- set :p4config, ".p4config" unless respond_to? :p4config
6
- end
7
-
8
- reset
3
+ set :p4_cmd, "p4"
4
+ set :source, Vlad::Perforce.new
9
5
 
10
6
  ##
11
7
  # Returns the p4 command that will checkout +revision+ into the directory
12
8
  # +destination+.
13
9
 
14
10
  def checkout(revision, destination)
15
- "#{p4cmd} sync ...#{rev_no(revision)}"
11
+ "#{p4_cmd} sync ...#{rev_no(revision)}"
16
12
  end
17
13
 
18
14
  ##
@@ -21,7 +17,7 @@ class Vlad::Perforce
21
17
 
22
18
  def export(revision_or_source, destination)
23
19
  if revision_or_source =~ /^(\d+|head)$/i then
24
- "(cd #{destination} && #{p4cmd} sync ...#{rev_no(revision_or_source)})"
20
+ "(cd #{destination} && #{p4_cmd} sync ...#{rev_no(revision_or_source)})"
25
21
  else
26
22
  "cp -r #{revision_or_source} #{destination}"
27
23
  end
@@ -32,7 +28,7 @@ class Vlad::Perforce
32
28
  # into a Perforce revision specification.
33
29
 
34
30
  def revision(revision)
35
- "`#{p4cmd} changes -s submitted -m 1 ...#{rev_no(revision)} | cut -f 2 -d\\ `"
31
+ "`#{p4_cmd} changes -s submitted -m 1 ...#{rev_no(revision)} | cut -f 2 -d\\ `"
36
32
  end
37
33
 
38
34
  ##
@@ -1,11 +1,14 @@
1
1
  class Vlad::Subversion
2
2
 
3
+ set :source, Vlad::Subversion.new
4
+ set :svn_cmd, "svn"
5
+
3
6
  ##
4
7
  # Returns the command that will check out +revision+ from the repository
5
8
  # into directory +destination+
6
9
 
7
10
  def checkout(revision, destination)
8
- "svn co -r #{revision} #{repository} #{destination}"
11
+ "#{svn_cmd} co -r #{revision} #{repository} #{destination}"
9
12
  end
10
13
 
11
14
  ##
@@ -14,9 +17,9 @@ class Vlad::Subversion
14
17
 
15
18
  def export(revision_or_source, destination)
16
19
  if revision_or_source =~ /^(\d+|head)$/i then
17
- "svn export -r #{revision_or_source} #{repository} #{destination}"
20
+ "#{svn_cmd} export -r #{revision_or_source} #{repository} #{destination}"
18
21
  else
19
- "svn export #{revision_or_source} #{destination}"
22
+ "#{svn_cmd} export #{revision_or_source} #{destination}"
20
23
  end
21
24
  end
22
25
 
@@ -25,6 +28,7 @@ class Vlad::Subversion
25
28
  # into a subversion revision specification.
26
29
 
27
30
  def revision(revision)
28
- "`svn info #{repository} | grep 'Revision:' | cut -f2 -d\\ `"
31
+ "`#{svn_cmd} info #{repository} | grep 'Revision:' | cut -f2 -d\\ `"
29
32
  end
30
33
  end
34
+
@@ -135,7 +135,12 @@ class TestRakeRemoteTask < VladTestCase
135
135
  commands.first
136
136
 
137
137
  assert_equal "my password\n", @task.input.string
138
- assert_equal "Password:\nfile1\nfile2\n", result
138
+
139
+ # WARN: Technically incorrect, the password line should be
140
+ # first... this is an artifact of changes to the IO code in run
141
+ # and the fact that we have a very simplistic (non-blocking)
142
+ # testing model.
143
+ assert_equal "file1\nfile2\nPassword:\n", result
139
144
 
140
145
  assert_equal "file1\nfile2\n", out.read
141
146
  assert_equal "Password:\n", err.read
data/test/test_vlad.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'test/vlad_test_case'
2
2
  require 'vlad'
3
3
 
4
+ $TESTING = true
5
+
4
6
  class TestVlad < VladTestCase
5
7
  def test_all_hosts
6
8
  util_set_hosts
@@ -66,8 +68,10 @@ class TestVlad < VladTestCase
66
68
  end
67
69
 
68
70
  def test_initialize
69
- assert_raise(Vlad::ConfigurationError) { @vlad.application }
71
+ @vlad.set_defaults # ensure these three are virginal
70
72
  assert_raise(Vlad::ConfigurationError) { @vlad.repository }
73
+ assert_raise(Vlad::ConfigurationError) { @vlad.deploy_to }
74
+ assert_raise(Vlad::ConfigurationError) { @vlad.domain }
71
75
  end
72
76
 
73
77
  def test_role
@@ -156,21 +160,6 @@ class TestVlad < VladTestCase
156
160
  assert_equal %w[master], task.target_hosts
157
161
  end
158
162
 
159
- def test_source
160
- set :scm, :perforce
161
- assert_equal "Vlad::Perforce", @vlad.source.class.name
162
- end
163
-
164
- def test_source_default
165
- assert_equal "Vlad::Subversion", @vlad.source.class.name
166
- end
167
-
168
- def test_source_singleton
169
- s1 = @vlad.source
170
- s2 = @vlad.source
171
- assert_equal s1.object_id, s2.object_id
172
- end
173
-
174
163
  def test_set
175
164
  set :test, 5
176
165
  assert_equal 5, @vlad.test
@@ -212,8 +201,11 @@ class TestVlad < VladTestCase
212
201
  end
213
202
 
214
203
  def test_set_with_reserved_name
204
+ $TESTING = false
215
205
  e = assert_raise(ArgumentError) { set(:all_hosts, []) }
216
206
  assert_equal "cannot set reserved name: 'all_hosts'", e.message
207
+ ensure
208
+ $TESTING = true
217
209
  end
218
210
  end
219
211
 
@@ -6,7 +6,6 @@ class TestVladPerforce < VladTestCase
6
6
  def setup
7
7
  super
8
8
  @scm = Vlad::Perforce.new
9
- Vlad::Perforce.reset
10
9
  end
11
10
 
12
11
  def test_checkout
@@ -2,8 +2,9 @@ require 'test/vlad_test_case'
2
2
  require 'vlad'
3
3
  require 'vlad/subversion'
4
4
 
5
- class TestVladSubversion < Test::Unit::TestCase
5
+ class TestVladSubversion < VladTestCase
6
6
  def setup
7
+ super
7
8
  @scm = Vlad::Subversion.new
8
9
  set :repository, "svn+ssh://repo/myproject"
9
10
  end
@@ -6,6 +6,18 @@ class StringIO
6
6
  def readpartial(size) read end # suck!
7
7
  end
8
8
 
9
+ module Process
10
+ def self.expected status
11
+ @@expected ||= []
12
+ @@expected << status
13
+ end
14
+
15
+ def self.waitpid2(pid)
16
+ [ @@expected.shift ]
17
+ end
18
+ end
19
+
20
+
9
21
  class Rake::RemoteTask
10
22
  attr_accessor :commands, :action, :input, :output, :error
11
23
 
@@ -27,10 +39,12 @@ class Rake::RemoteTask
27
39
  out = StringIO.new @output.shift.to_s
28
40
  err = StringIO.new @error.shift.to_s
29
41
 
30
- yield 42, @input, out, err
42
+ raise if block_given?
31
43
 
32
44
  status = self.action ? self.action[command.join(' ')] : 0
33
- Status.new status
45
+ Process.expected Status.new(status)
46
+
47
+ return 42, @input, out, err
34
48
  end
35
49
 
36
50
  def select reads, writes, errs, timeout
@@ -44,16 +58,12 @@ class VladTestCase < Test::Unit::TestCase
44
58
 
45
59
  def setup
46
60
  @vlad = Rake::RemoteTask
61
+ @vlad.reset
47
62
  Rake.application.clear
48
63
  @task_count = Rake.application.tasks.size
49
64
  @vlad.set :domain, "example.com"
50
65
  end
51
66
 
52
- def teardown
53
- @vlad.env.keys.each { |k| Object.send(:remove_method, k) if @vlad.respond_to?(k) }
54
- @vlad.reset
55
- end
56
-
57
67
  def util_set_hosts
58
68
  @vlad.host "app.example.com", :app
59
69
  @vlad.host "db.example.com", :db
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: vlad
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2007-08-13 00:00:00 -07:00
8
- summary: The author was too lazy to write a summary
6
+ version: 1.1.0
7
+ date: 2007-09-12 00:00:00 -07:00
8
+ summary: Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync.
9
9
  require_paths:
10
10
  - lib
11
11
  email: ryand-ruby@zenspider.com
12
12
  homepage: http://rubyhitsquad.com/
13
13
  rubyforge_project: hitsquad
14
- description: "Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync. Impale your application on the heartless spike of the Deployer. == FEATURES/PROBLEMS: * Full deployment automation stack. * Supports single server deployment with just 4 variables defined. * Very few dependencies. All simple. * Uses ssh with your ssh settings already in place. * Uses rsync for efficient transfers. * Run remote commands on one or more servers. * Syncs files to one or more servers. * Mix and match local and remote tasks. * Built on rake. easy. * Compatible with all of your tab completion shell script rake-tastic goodness. * Ships with tests that actually pass. * Engine is under 500 lines of code. * Super uper simple. * Does NOT support Windows right now. Coming soon in 1.1. * This is 1.0.0... expect rough edges."
14
+ description: "Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync. Impale your application on the heartless spike of the Deployer. == FEATURES/PROBLEMS: * Full deployment automation stack. * Turnkey deployment for mongrel+apache+svn. * Supports single server deployment with just 3 variables defined. * Built on rake. Easy. Engine is small. * Very few dependencies. All simple. * Uses ssh with your ssh settings already in place. * Uses rsync for efficient transfers. * Run remote commands on one or more servers. * Mix and match local and remote tasks. * Compatible with all of your tab completion shell script rake-tastic goodness. * Ships with tests that actually pass in 0.028 seconds! * Does NOT support Windows right now (we think). Coming soon in 1.2."
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
@@ -36,15 +36,18 @@ files:
36
36
  - README.txt
37
37
  - Rakefile
38
38
  - considerations.txt
39
+ - doco/faq.txt
39
40
  - doco/getting_started.txt
40
41
  - doco/migration.txt
41
42
  - doco/perforce.txt
42
43
  - doco/variables.txt
43
44
  - lib/rake_remote_task.rb
44
45
  - lib/vlad.rb
46
+ - lib/vlad/apache.rb
47
+ - lib/vlad/core.rb
48
+ - lib/vlad/mongrel.rb
45
49
  - lib/vlad/perforce.rb
46
50
  - lib/vlad/subversion.rb
47
- - lib/vlad_tasks.rb
48
51
  - test/test_rake_remote_task.rb
49
52
  - test/test_vlad.rb
50
53
  - test/test_vlad_perforce.rb
@@ -63,6 +66,7 @@ extra_rdoc_files:
63
66
  - Manifest.txt
64
67
  - README.txt
65
68
  - considerations.txt
69
+ - doco/faq.txt
66
70
  - doco/getting_started.txt
67
71
  - doco/migration.txt
68
72
  - doco/perforce.txt