Class: Teapot::Select

Inherits:
Object
  • Object
show all
Defined in:
lib/teapot/select.rb

Overview

A selection is a specific view of the data exposed by the context at a specific point in time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, configuration, names = []) ⇒ Select

Initialize a new selection.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/teapot/select.rb', line 38

def initialize(context, configuration, names = [])
	@context = context
	@configuration = Configuration.new(context, configuration.package, configuration.name, [], **configuration.options)
	
	@targets = {}
	@configurations = {}
	@projects = {}
	
	@dependencies = []
	@selection = Set.new
	@resolved = Build::Dependency::Set.new
	@unresolved = Build::Dependency::Set.new
	
	load!(configuration, names)
	
	@chain = nil
end

Instance Attribute Details

#aliasesObject (readonly)

Alises as defined by Configuration#targets



63
64
65
# File 'lib/teapot/select.rb', line 63

def aliases
  @aliases
end

#configurationObject (readonly)

Returns the value of attribute configuration.



57
58
59
# File 'lib/teapot/select.rb', line 57

def configuration
  @configuration
end

#configurationsObject (readonly)

All public configurations.



66
67
68
# File 'lib/teapot/select.rb', line 66

def configurations
  @configurations
end

#contextObject (readonly)

Returns the value of attribute context.



56
57
58
# File 'lib/teapot/select.rb', line 56

def context
  @context
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



68
69
70
# File 'lib/teapot/select.rb', line 68

def dependencies
  @dependencies
end

#projectsObject (readonly)

Returns the value of attribute projects.



60
61
62
# File 'lib/teapot/select.rb', line 60

def projects
  @projects
end

#resolvedObject (readonly)

Returns the value of attribute resolved.



71
72
73
# File 'lib/teapot/select.rb', line 71

def resolved
  @resolved
end

#selectionObject (readonly)

Returns the value of attribute selection.



69
70
71
# File 'lib/teapot/select.rb', line 69

def selection
  @selection
end

#targetsObject (readonly)

Returns the value of attribute targets.



59
60
61
# File 'lib/teapot/select.rb', line 59

def targets
  @targets
end

#unresolvedObject (readonly)

Returns the value of attribute unresolved.



72
73
74
# File 'lib/teapot/select.rb', line 72

def unresolved
  @unresolved
end

Instance Method Details

#chainObject

Get the dependency chain.



76
77
78
# File 'lib/teapot/select.rb', line 76

def chain
	@chain ||= Build::Dependency::Chain.expand(@dependencies, @targets.values, @selection)
end

#direct_targets(ordered) ⇒ Object

Extract the targets that directly satisfy the requested dependencies.



83
84
85
86
87
# File 'lib/teapot/select.rb', line 83

def direct_targets(ordered)
	@dependencies.collect do |dependency|
		ordered.find{|(package, _)| package.provides? dependency}
	end.compact
end