Class: CobraCommander::Affected
- Inherits:
-
Object
- Object
- CobraCommander::Affected
- Includes:
- Enumerable
- Defined in:
- lib/cobra_commander/affected.rb
Overview
Calculates directly & transitively affected components Takes a list of changes, and resolves all components affected
Instance Method Summary collapse
- #directly ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(umbrella, changes) ⇒ Affected
constructor
A new instance of Affected.
- #transitively ⇒ Object
Constructor Details
#initialize(umbrella, changes) ⇒ Affected
Returns a new instance of Affected.
10 11 12 13 |
# File 'lib/cobra_commander/affected.rb', line 10 def initialize(umbrella, changes) @umbrella = umbrella @changes = changes end |
Instance Method Details
#directly ⇒ Object
19 20 21 22 |
# File 'lib/cobra_commander/affected.rb', line 19 def directly @directly ||= @changes.filter_map { |path| @umbrella.resolve(path) } .uniq.sort_by(&:name) end |
#each(&block) ⇒ Object
15 16 17 |
# File 'lib/cobra_commander/affected.rb', line 15 def each(&block) (directly | transitively).sort_by(&:name).each(&block) end |
#transitively ⇒ Object
24 25 26 27 |
# File 'lib/cobra_commander/affected.rb', line 24 def transitively @transitively ||= directly.flat_map(&:deep_dependents) .uniq.sort_by(&:name) end |