Class: CobraCommander::Component
- Inherits:
-
Object
- Object
- CobraCommander::Component
- Defined in:
- lib/cobra_commander/component.rb
Overview
Represents a component withing an Umbrella
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
- #add_source(key, path, dependency_names) ⇒ Object
- #deep_dependencies ⇒ Object
- #deep_dependents ⇒ Object
- #dependencies ⇒ Object
- #dependents ⇒ Object
-
#initialize(umbrella, name) ⇒ Component
constructor
A new instance of Component.
- #inspect ⇒ Object
- #root_paths ⇒ Object
Constructor Details
#initialize(umbrella, name) ⇒ Component
Returns a new instance of Component.
8 9 10 11 12 13 |
# File 'lib/cobra_commander/component.rb', line 8 def initialize(umbrella, name) @umbrella = umbrella @name = name @dependency_names = [] @sources = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/cobra_commander/component.rb', line 6 def name @name end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
6 7 8 |
# File 'lib/cobra_commander/component.rb', line 6 def sources @sources end |
Instance Method Details
#add_source(key, path, dependency_names) ⇒ Object
15 16 17 18 |
# File 'lib/cobra_commander/component.rb', line 15 def add_source(key, path, dependency_names) @sources[key] = path @dependency_names |= dependency_names end |
#deep_dependencies ⇒ Object
34 35 36 37 38 |
# File 'lib/cobra_commander/component.rb', line 34 def deep_dependencies @deep_dependencies ||= dependencies.reduce(dependencies) do |deps, dep| deps | dep.deep_dependencies end end |
#deep_dependents ⇒ Object
28 29 30 31 32 |
# File 'lib/cobra_commander/component.rb', line 28 def deep_dependents @deep_dependents ||= @umbrella.components.find_all do |dep| dep.deep_dependencies.include?(self) end end |
#dependencies ⇒ Object
46 47 48 49 50 |
# File 'lib/cobra_commander/component.rb', line 46 def dependencies @dependencies ||= @dependency_names.sort .map(&@umbrella.method(:find)) .compact end |
#dependents ⇒ Object
40 41 42 43 44 |
# File 'lib/cobra_commander/component.rb', line 40 def dependents @dependents ||= @umbrella.components.find_all do |dep| dep.dependencies.include?(self) end end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/cobra_commander/component.rb', line 24 def inspect "#<CobraCommander::Component:#{object_id} #{name} dependencies=#{dependencies.map(&:name)} packages=#{sources}>" end |
#root_paths ⇒ Object
20 21 22 |
# File 'lib/cobra_commander/component.rb', line 20 def root_paths @sources.values.map(&File.method(:dirname)).uniq end |