Class: CfDeployer::Component
- Inherits:
-
Object
- Object
- CfDeployer::Component
- Defined in:
- lib/cf_deployer/component.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #depends_on?(component, source = self) ⇒ Boolean
- #deploy ⇒ Object
- #destroy ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(application_name, environment_name, component_name, context) ⇒ Component
constructor
A new instance of Component.
- #inspect ⇒ Object
- #json ⇒ Object
- #kill_inactive ⇒ Object
- #output_value(key) ⇒ Object
- #status(get_resource_statuses) ⇒ Object
- #switch ⇒ Object
Constructor Details
#initialize(application_name, environment_name, component_name, context) ⇒ Component
Returns a new instance of Component.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/cf_deployer/component.rb', line 5 def initialize(application_name, environment_name, component_name, context) @application_name = application_name @environment_name = environment_name @name = component_name @context = context @dependencies = [] @children = [] Log.debug "initializing #{name}.." Log.debug @context end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
3 4 5 |
# File 'lib/cf_deployer/component.rb', line 3 def children @children end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
3 4 5 |
# File 'lib/cf_deployer/component.rb', line 3 def dependencies @dependencies end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/cf_deployer/component.rb', line 3 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cf_deployer/component.rb', line 53 def <=>(other) i_am_depednent = depends_on? other it_is_dependent = other.depends_on? self if i_am_depednent 1 elsif it_is_dependent -1 else 0 end end |
#depends_on?(component, source = self) ⇒ Boolean
70 71 72 73 |
# File 'lib/cf_deployer/component.rb', line 70 def depends_on?(component, source=self) raise ApplicationError.new("Cyclic dependency") if @dependencies.include?(source) @dependencies.include?(component) || @dependencies.any? { |d| d.depends_on?(component, source) } end |
#deploy ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/cf_deployer/component.rb', line 24 def deploy Log.debug "deploying #{name}..." @dependencies.each do |parent| parent.deploy unless(parent.exists?) end resolve_settings strategy.deploy end |
#destroy ⇒ Object
39 40 41 42 |
# File 'lib/cf_deployer/component.rb', line 39 def destroy raise ApplicationError.new("Unable to destroy #{name}, it is depended on by other components") if any_children_exist? strategy.destroy end |
#exists? ⇒ Boolean
16 17 18 |
# File 'lib/cf_deployer/component.rb', line 16 def exists? strategy.exists? end |
#inspect ⇒ Object
66 67 68 |
# File 'lib/cf_deployer/component.rb', line 66 def inspect "component: #{name}" end |
#json ⇒ Object
33 34 35 36 37 |
# File 'lib/cf_deployer/component.rb', line 33 def json resolve_settings puts "#{name} json template:" puts ConfigLoader.component_json(name, @context) end |
#kill_inactive ⇒ Object
20 21 22 |
# File 'lib/cf_deployer/component.rb', line 20 def kill_inactive strategy.kill_inactive end |
#output_value(key) ⇒ Object
49 50 51 |
# File 'lib/cf_deployer/component.rb', line 49 def output_value(key) strategy.output_value(key) end |
#status(get_resource_statuses) ⇒ Object
75 76 77 |
# File 'lib/cf_deployer/component.rb', line 75 def status get_resource_statuses strategy.status get_resource_statuses end |
#switch ⇒ Object
44 45 46 |
# File 'lib/cf_deployer/component.rb', line 44 def switch exists? ? strategy.switch : (raise ApplicationError.new("No stack exists for component: #{name}")) end |