forked from auser/poolparty
/
capistrano_configurer.rb
69 lines (61 loc) · 1.94 KB
/
capistrano_configurer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
=begin rdoc
This overwriting of the Capistrano method missing allows our capistrano
tasks to have access to the methods on the provisioner and options
set on the clouds. This saves us the responsibility of setting variables
in the dynamic cap file.
=end
#TODO# Clean up
module Capistrano
class Configuration
attr_accessor :cloud, :provisioner
def method_missing_without_variables(sym, *args, &block)
if parent.respond_to?(sym)
parent.send(sym, *args, &block)
elsif provisioner.respond_to?(sym)
provisioner.send(sym, *args, &block)
elsif cloud.respond_to?(sym)
cloud.send(sym, *args, &block)
elsif PoolParty::Default.options.has_key?(sym)
PoolParty::Default.options[sym]
elsif PoolParty::Default.respond_to?(sym)
PoolParty::Default.send(sym, *args, &block)
else
super
end
end
module Namespaces
class Namespace
def provisioner
parent.provisioner
end
def cloud(name=nil)
puts "name: #{name}"
name ? PoolParty::Cloud.clouds[name] : parent.cloud
end
def parent
cloud
end
def method_missing(sym, *args, &block)
# if parent
# parent.send(sym, *args, &block) rescue super
# else
# super
# end
if parent.respond_to?(sym)
parent.send(sym, *args, &block)
elsif provisioner.respond_to?(sym)
provisioner.send(sym, *args, &block)
elsif cloud.respond_to?(sym)
cloud.send(sym, *args, &block)
elsif PoolParty::Default.options.has_key?(sym)
PoolParty::Default.options[sym]
elsif PoolParty::Default.respond_to?(sym)
PoolParty::Default.send(sym, *args, &block)
else
super
end
end
end
end
end
end