class Teapot::Select
A selection is a specific view of the data exposed by the context at a specific point in time.
Attributes
aliases[R]
Alises as defined by Configuration#targets
configuration[R]
configurations[R]
All public configurations.
context[R]
dependencies[R]
projects[R]
resolved[R]
selection[R]
targets[R]
unresolved[R]
Public Class Methods
new(context, configuration, names = [])
click to toggle source
# 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
Public Instance Methods
chain()
click to toggle source
# File lib/teapot/select.rb, line 79 def chain @chain ||= Build::Dependency::Chain.expand(@dependencies, @targets.values, @selection) end
direct_targets(ordered)
click to toggle source
# File lib/teapot/select.rb, line 83 def direct_targets(ordered) @dependencies.collect do |dependency| ordered.find{|(package, _)| package.provides? dependency} end.compact end
Private Instance Methods
append(definition)
click to toggle source
Add a definition to the current context.
# File lib/teapot/select.rb, line 92 def append definition case definition when Target AlreadyDefinedError.check(definition, @targets) @targets[definition.name] = definition when Configuration # We define configurations in two cases, if they are public, or if they are part of the root package of this context. if definition.public? or definition.package == @context.root_package AlreadyDefinedError.check(definition, @configurations) @configurations[definition.name] = definition end when Project AlreadyDefinedError.check(definition, @projects) @projects[definition.name] = definition end end
load!(configuration, names)
click to toggle source
# File lib/teapot/select.rb, line 125 def load!(configuration, names) # Load the root package which makes all the named configurations and targets available. load_package!(@context.root_package) # Load all packages defined by this configuration. configuration.traverse(@configurations) do |configuration| @configuration.merge(configuration) do |package| # puts "Load package: #{package} from #{configuration}" load_package!(package) end end @configuration.freeze names.each do |name| if @targets.key? name @selection << name else @dependencies << name end end end
load_package!(package)
click to toggle source
# File lib/teapot/select.rb, line 109 def load_package!(package) begin script = @context.load(package) # Load the definitions into the current selection: script.defined.each do |definition| append(definition) end @resolved << package rescue MissingTeapotError, IncompatibleTeapotError # If the package doesn't exist or the teapot version is too old, it failed: @unresolved << package end end