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

Returns a new instance of Select.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/teapot/select.rb', line 43

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



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

def aliases
  @aliases
end

#configurationObject (readonly)

Returns the value of attribute configuration.



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

def configuration
  @configuration
end

#configurationsObject (readonly)

All public configurations.



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

def configurations
  @configurations
end

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



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

def dependencies
  @dependencies
end

#projectsObject (readonly)

Returns the value of attribute projects.



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

def projects
  @projects
end

#resolvedObject (readonly)

Returns the value of attribute resolved.



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

def resolved
  @resolved
end

#selectionObject (readonly)

Returns the value of attribute selection.



74
75
76
# File 'lib/teapot/select.rb', line 74

def selection
  @selection
end

#targetsObject (readonly)

Returns the value of attribute targets.



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

def targets
  @targets
end

#unresolvedObject (readonly)

Returns the value of attribute unresolved.



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

def unresolved
  @unresolved
end

Instance Method Details

#chainObject



79
80
81
# File 'lib/teapot/select.rb', line 79

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

#direct_targets(ordered) ⇒ Object



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