Class: Build::Dependency::Chain

Inherits:
Resolver
  • Object
show all
Defined in:
lib/build/dependency/chain.rb,
lib/build/dependency/partial_chain.rb

Instance Attribute Summary collapse

Attributes inherited from Resolver

#conflicts, #ordered, #provisions, #resolved, #unresolved

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependencies, providers, selection = []) ⇒ Chain

Returns a new instance of Chain.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/build/dependency/chain.rb', line 39

def initialize(dependencies, providers, selection = [])
	super()
	
	# Explicitly selected dependencies which will be used when resolving ambiguity:
	@selection = Set.new(selection)
	
	# The list of dependencies that needs to be satisfied:
	@dependencies = dependencies.collect{|dependency| Depends[dependency]}
	
	# The available providers which match up to required dependencies:
	@providers = providers
	
	expand_top
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



55
56
57
# File 'lib/build/dependency/chain.rb', line 55

def dependencies
  @dependencies
end

#providersObject (readonly)

Returns the value of attribute providers.



56
57
58
# File 'lib/build/dependency/chain.rb', line 56

def providers
  @providers
end

#selectionObject (readonly)

Returns the value of attribute selection.



54
55
56
# File 'lib/build/dependency/chain.rb', line 54

def selection
  @selection
end

Class Method Details

.expand(*args) ⇒ Object

An ‘UnresolvedDependencyError` will be thrown if there are any unresolved dependencies.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/build/dependency/chain.rb', line 27

def self.expand(*args)
	chain = self.new(*args)
	
	chain.freeze
	
	if chain.unresolved.size > 0
		raise UnresolvedDependencyError.new(chain)
	end
	
	return chain
end

Instance Method Details

#freezeObject



58
59
60
61
62
63
64
65
66
# File 'lib/build/dependency/chain.rb', line 58

def freeze
	return unless frozen?
	
	@selection.freeze
	@dependencies.freeze
	@providers.freeze
	
	super
end

#partial(provider) ⇒ Object



26
27
28
# File 'lib/build/dependency/partial_chain.rb', line 26

def partial(provider)
	PartialChain.expand(self, provider.dependencies)
end