Class: BrighterPlanet::Deploy::Server
Defined Under Namespace
Classes: InvalidKey
Constant Summary
collapse
- PUBLIC =
[:color]
- NOT_SAVED =
[:local, :status, :rails_root, :public_dir, :private_dir]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#from_private_dir, #from_public_dir, #save, #write
Constructor Details
#initialize(attrs = {}) ⇒ Server
Returns a new instance of Server.
20
21
22
23
24
|
# File 'lib/brighter_planet_deploy/server.rb', line 20
def initialize(attrs = {})
attrs.each do |k, v|
instance_variable_set "@#{k}", v
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args) ⇒ Object
71
72
73
74
75
76
77
78
79
|
# File 'lib/brighter_planet_deploy/server.rb', line 71
def method_missing(method_id, *args)
if method_id.to_s.end_with?('=') and args.length == 1
instance_variable_set "@#{method_id.to_s.chomp('=')}", args[0]
elsif args.length == 0 and not block_given?
lookup method_id
else
super
end
end
|
Instance Attribute Details
#environment ⇒ Object
55
56
57
|
# File 'lib/brighter_planet_deploy/server.rb', line 55
def environment
@environment || lookup(:environment) || local_rails_environment
end
|
#hostname ⇒ Object
60
61
62
|
# File 'lib/brighter_planet_deploy/server.rb', line 60
def hostname
@hostname || lookup(:hostname) || local_hostname
end
|
#private_dir ⇒ Object
44
45
46
|
# File 'lib/brighter_planet_deploy/server.rb', line 44
def private_dir
@private_dir || ::File.join(rails_root, 'config')
end
|
#public_dir ⇒ Object
38
39
40
|
# File 'lib/brighter_planet_deploy/server.rb', line 38
def public_dir
@public_dir || ::File.join(rails_root, 'public')
end
|
#rails_root ⇒ Object
32
33
34
|
# File 'lib/brighter_planet_deploy/server.rb', line 32
def rails_root
@rails_root || local_rails_root
end
|
#status ⇒ Object
50
51
52
|
# File 'lib/brighter_planet_deploy/server.rb', line 50
def status
@status || (color == service_model.color ? :active : :standby)
end
|
Class Method Details
.me ⇒ Object
15
16
17
|
# File 'lib/brighter_planet_deploy/server.rb', line 15
def me
@me ||= new :local => true
end
|
Instance Method Details
#local? ⇒ Boolean
26
27
28
|
# File 'lib/brighter_planet_deploy/server.rb', line 26
def local?
!!@local
end
|
#not_saved?(k) ⇒ Boolean
85
86
87
|
# File 'lib/brighter_planet_deploy/server.rb', line 85
def not_saved?(k)
NOT_SAVED.include? k.to_sym
end
|
#public?(k) ⇒ Boolean
81
82
83
|
# File 'lib/brighter_planet_deploy/server.rb', line 81
def public?(k)
PUBLIC.include? k.to_sym
end
|
#service_model ⇒ Object
64
65
66
67
68
69
|
# File 'lib/brighter_planet_deploy/server.rb', line 64
def service_model
case service.to_s.underscore
when 'cm1'
Cm1.instance
end
end
|