Class: Librarian::Resolver::Implementation

Inherits:
Object
  • Object
show all
Defined in:
lib/librarian/resolver/implementation.rb

Defined Under Namespace

Classes: MultiSource, State

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resolver, spec, options = { }) ⇒ Implementation

Returns a new instance of Implementation.



36
37
38
39
40
41
42
43
44
# File 'lib/librarian/resolver/implementation.rb', line 36

def initialize(resolver, spec, options = { })
  unrecognized_options = options.keys - [:cyclic]
  unrecognized_options.empty? or raise Error,
    "unrecognized options: #{unrecognized_options.join(", ")}"
  self.resolver = resolver
  self.spec = spec
  self.cyclic = !!options[:cyclic]
  @level = 0
end

Instance Attribute Details

#cyclicObject

Returns the value of attribute cyclic.



33
34
35
# File 'lib/librarian/resolver/implementation.rb', line 33

def cyclic
  @cyclic
end

#resolverObject

Returns the value of attribute resolver.



33
34
35
# File 'lib/librarian/resolver/implementation.rb', line 33

def resolver
  @resolver
end

#specObject

Returns the value of attribute spec.



33
34
35
# File 'lib/librarian/resolver/implementation.rb', line 33

def spec
  @spec
end

Instance Method Details

#resolve(manifests) ⇒ Object



46
47
48
49
50
51
# File 'lib/librarian/resolver/implementation.rb', line 46

def resolve(manifests)
  manifests = index_by(manifests, &:name) if manifests.kind_of?(Array)
  queue = spec.dependencies + sourced_dependencies_for_manifests(manifests)
  state = State.new(manifests.dup, [], queue)
  recursive_resolve(state)
end