Class: Librarian::Resolver

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

Defined Under Namespace

Classes: Implementation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, options = { }) ⇒ Resolver

Options:

cyclic: truthy if the resolver should permit cyclic resolutions


14
15
16
17
18
19
20
# File 'lib/librarian/resolver.rb', line 14

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

Instance Attribute Details

#cyclicObject

Returns the value of attribute cyclic.



9
10
11
# File 'lib/librarian/resolver.rb', line 9

def cyclic
  @cyclic
end

#environmentObject

Returns the value of attribute environment.



9
10
11
# File 'lib/librarian/resolver.rb', line 9

def environment
  @environment
end

Instance Method Details

#resolve(spec, partial_manifests = []) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/librarian/resolver.rb', line 22

def resolve(spec, partial_manifests = [])
  manifests = implementation(spec).resolve(partial_manifests)
  manifests or return
  enforce_consistency!(spec.dependencies, manifests)
  enforce_acyclicity!(manifests) unless cyclic
  manifests = sort(manifests)
  Resolution.new(spec.dependencies, manifests)
end