mattmatt-cap-ext-webistrano 0.1.0 → 0.1.1
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/Rakefile +1 -0
- data/VERSION.yml +1 -1
- data/lib/cap_ext_webistrano.rb +7 -4
- data/lib/cap_ext_webistrano/task.rb +1 -1
- data/test/cap_ext_webistrano_shoulda.rb +25 -0
- data/test/capistrano_stub.rb +39 -0
- metadata +13 -2
data/Rakefile
CHANGED
@@ -12,6 +12,7 @@ begin
|
|
12
12
|
s.authors = ["Mathias Meyer"]
|
13
13
|
s.files = FileList["[A-Z]*", "{lib,test}/**/*"]
|
14
14
|
s.add_dependency 'capistrano'
|
15
|
+
s.add_dependency 'activeresource'
|
15
16
|
end
|
16
17
|
rescue LoadError
|
17
18
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
data/VERSION.yml
CHANGED
data/lib/cap_ext_webistrano.rb
CHANGED
@@ -5,7 +5,7 @@ require 'cap_ext_webistrano/project'
|
|
5
5
|
|
6
6
|
module CapExtWebistrano
|
7
7
|
def task(*args, &blk)
|
8
|
-
original_task(*args,
|
8
|
+
original_task(*args, &hijack_runner)
|
9
9
|
end
|
10
10
|
|
11
11
|
def after(*args)
|
@@ -26,10 +26,13 @@ end
|
|
26
26
|
Capistrano::Configuration::Execution.class_eval do
|
27
27
|
alias :original_find_and_execute_task :find_and_execute_task
|
28
28
|
|
29
|
+
def hijack_runner
|
30
|
+
@hijack_runner ||= lambda { CapExtWebistrano::Task.new(current_task.fully_qualified_name, self).run }
|
31
|
+
end
|
32
|
+
|
29
33
|
def hijack_capistrano
|
30
|
-
|
31
|
-
tasks.each {|tsk| tsk.last.instance_variable_set(:@body,
|
32
|
-
namespaces.each {|nmspace| nmspace.last.tasks.each {|tsk| tsk.last.instance_variable_set(:@body, @hijack_runner)}}
|
34
|
+
tasks.each {|tsk| tsk.last.instance_variable_set(:@body, hijack_runner)}
|
35
|
+
namespaces.each {|nmspace| nmspace.last.tasks.each {|tsk| tsk.last.instance_variable_set(:@body, hijack_runner)}}
|
33
36
|
end
|
34
37
|
|
35
38
|
def find_and_execute_task(task, hooks = {})
|
@@ -22,7 +22,7 @@ module CapExtWebistrano
|
|
22
22
|
still_running = true
|
23
23
|
while still_running
|
24
24
|
sleep 5
|
25
|
-
@deployment
|
25
|
+
@deployment.reload
|
26
26
|
print_diff(@deployment)
|
27
27
|
still_running = false unless @deployment.completed_at.nil?
|
28
28
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.unshift(File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'cap_ext_webistrano'
|
5
|
+
require 'capistrano_stub'
|
6
|
+
require 'cap_ext_webistrano/task'
|
7
|
+
|
8
|
+
class CapExtWebistranoTest < Test::Unit::TestCase
|
9
|
+
context "when executing tasks" do
|
10
|
+
setup do
|
11
|
+
@cap = CapistranoStub.new
|
12
|
+
CapExtWebistrano::Task.stubs(:new).returns @cap
|
13
|
+
end
|
14
|
+
|
15
|
+
should "convert all tasks to use the hijacking task" do
|
16
|
+
@cap.find_and_execute_task("deploy")
|
17
|
+
assert_nothing_raised {@cap.task.body.call}
|
18
|
+
end
|
19
|
+
|
20
|
+
should "call run on the task runner" do
|
21
|
+
@cap.find_and_execute_task("deploy")
|
22
|
+
assert @cap.ran
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
class CapistranoStub
|
4
|
+
include Capistrano::Configuration::Namespaces
|
5
|
+
include Capistrano::Configuration::Execution
|
6
|
+
attr_accessor :task, :ran
|
7
|
+
|
8
|
+
def logger
|
9
|
+
Logger.new(STDOUT)
|
10
|
+
end
|
11
|
+
|
12
|
+
def find_task(*args)
|
13
|
+
@task ||= Capistrano::TaskDefinition.new("deploy", top, {}) { raise "This shouldn't be raised" }
|
14
|
+
end
|
15
|
+
|
16
|
+
def original_find_and_execute_task(*args)
|
17
|
+
find_task.body.call
|
18
|
+
end
|
19
|
+
|
20
|
+
def namespaces
|
21
|
+
{:default => top}
|
22
|
+
end
|
23
|
+
|
24
|
+
def tasks
|
25
|
+
@tasks = {"deploy" => find_task}
|
26
|
+
end
|
27
|
+
|
28
|
+
def current_task
|
29
|
+
find_task
|
30
|
+
end
|
31
|
+
|
32
|
+
def [](key)
|
33
|
+
"admin"
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
@ran = true
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mattmatt-cap-ext-webistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Meyer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-22 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +21,15 @@ dependencies:
|
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: "0"
|
23
23
|
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: activeresource
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
24
33
|
description:
|
25
34
|
email: meyer@paperplanes.de
|
26
35
|
executables: []
|
@@ -39,6 +48,8 @@ files:
|
|
39
48
|
- lib/cap_ext_webistrano/stage.rb
|
40
49
|
- lib/cap_ext_webistrano/task.rb
|
41
50
|
- lib/cap_ext_webistrano.rb
|
51
|
+
- test/cap_ext_webistrano_shoulda.rb
|
52
|
+
- test/capistrano_stub.rb
|
42
53
|
- test/project_shoulda.rb
|
43
54
|
- test/task_shoulda.rb
|
44
55
|
- test/test_helper.rb
|