Class: ExcADG::DependencyManager

Inherits:
Object
  • Object
show all
Defined in:
lib/excadg/dependency_manager.rb

Overview

manage list of dependencies dependencies could be of 2 types:

  • vertex - see vertex.rb

  • symbol - :name attribute of the vertex

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deps:) ⇒ DependencyManager

Returns a new instance of DependencyManager.

Parameters:

  • deps

    list of symbols or vertices to watch for as dependencies



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/excadg/dependency_manager.rb', line 16

def initialize deps:
  Assertions.is_a? deps, Array
  Assertions.is_a? deps, [Vertex, Symbol]

  @deps = deps.collect { |raw_dep|
    case raw_dep
    when Symbol then VStateData::Key.new name: raw_dep
    when Vertex then VStateData::Key.new vertex: raw_dep
    end
  }
  @data = []
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



13
14
15
# File 'lib/excadg/dependency_manager.rb', line 13

def data
  @data
end

#depsObject (readonly)

Returns the value of attribute deps.



13
14
15
# File 'lib/excadg/dependency_manager.rb', line 13

def deps
  @deps
end

Instance Method Details

#deduct_deps(new_data) ⇒ Object

deduct (update) dependencies with new data

  • counts :done dependencies

  • preserves :done deps data

Parameters:

  • new_data
    • Array of VStateData retrieved from the broker



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/excadg/dependency_manager.rb', line 33

def deduct_deps new_data
  data = filter_foreign new_data
  Log.debug "received deps: #{data}"

  assert_failed data

  done_deps = data.select(&:done?)
  @data += done_deps
  Log.debug "done deps: #{done_deps}"

  @deps.reject! { |dep| done_deps.include? dep }
  Log.info "deps left: #{@deps.collect(&:to_s)}}"
end