lib/teapot/context.rb in teapot-0.7.2 vs lib/teapot/context.rb in teapot-0.7.3
- old
+ new
@@ -53,32 +53,55 @@
# Load the root package:
defined = load(root_package)
# Find the default configuration, if it exists:
+
@default_configuration = defined.default_configuration
+
+ if options[:configuration]
+ @configuration = @configurations[options[:configuration]]
+ else
+ @configuration = @default_configuration
+ end
+
+ # Materialize the configuration:
+ @configuration = @configuration.materialize if @configuration
end
attr :root
attr :options
attr :targets
attr :generators
+
+ # All public configurations.
attr :configurations
+ # The context's primary configuration.
+ attr :configuration
+
+ attr :dependencies
+ attr :selection
+
def select(names)
names.each do |name|
if @targets.key? name
@selection << name
else
@dependencies << name
end
end
end
- attr :dependencies
- attr :selection
+ def dependency_chain(dependency_names, configuration = @configuration)
+ configuration.load_all
+
+ select(dependency_names)
+
+ Dependency::chain(@selection, @dependencies, @targets.values)
+ end
def direct_targets(ordered)
@dependencies.collect do |dependency|
ordered.find{|(package, _)| package.provides? dependency}
end.compact
@@ -120,23 +143,9 @@
self << definition
end
# Save the definitions per-package:
@loaded[package] = loader.defined
- end
- end
-
- attr :default_configuration
-
- def configuration_named(name)
- if name == DEFAULT_CONFIGURATION_NAME
- configuration = @default_configuration
- else
- configuration = @configurations[name]
- end
-
- if configuration
- configuration.materialize
end
end
def unresolved(packages)
failed_to_load = Set.new