Class: CobraCommander::Umbrella
- Inherits:
-
Object
- Object
- CobraCommander::Umbrella
- Defined in:
- lib/cobra_commander/umbrella.rb
Overview
An umbrella application
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add_source(key, source) ⇒ Object
- #components ⇒ Object
- #dependencies_of(name) ⇒ Object
- #dependents_of(component) ⇒ Object
- #find(name) ⇒ Object
-
#initialize(name, path) ⇒ Umbrella
constructor
A new instance of Umbrella.
- #resolve(component_root_path) ⇒ Object
- #root ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/cobra_commander/umbrella.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/cobra_commander/umbrella.rb', line 6 def path @path end |
Instance Method Details
#add_source(key, source) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/cobra_commander/umbrella.rb', line 30 def add_source(key, source) @root_component.add_source key, source.path, source.dependencies source.components.each do |component| @components[component[:name]] ||= Component.new(self, component[:name]) @components[component[:name]].add_source key, component[:path], component[:dependencies] end end |
#components ⇒ Object
38 39 40 |
# File 'lib/cobra_commander/umbrella.rb', line 38 def components @components.values end |
#dependencies_of(name) ⇒ Object
47 48 49 50 |
# File 'lib/cobra_commander/umbrella.rb', line 47 def dependencies_of(name) find(name)&.deep_dependencies &.sort_by(&:name) end |
#dependents_of(component) ⇒ Object
42 43 44 45 |
# File 'lib/cobra_commander/umbrella.rb', line 42 def dependents_of(component) find(component)&.deep_dependents &.sort_by(&:name) end |
#find(name) ⇒ Object
14 15 16 |
# File 'lib/cobra_commander/umbrella.rb', line 14 def find(name) @components[name] end |
#resolve(component_root_path) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/cobra_commander/umbrella.rb', line 22 def resolve(component_root_path) return root if root.root_paths.include?(component_root_path) components.find do |component| component.root_paths.include?(component_root_path) end end |
#root ⇒ Object
18 19 20 |
# File 'lib/cobra_commander/umbrella.rb', line 18 def root @root_component end |