Sha256: ea4ba1654c81a0677ba9a360872e1ce0253496ceb09c3a3467acd1bd7275c9e4
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
module Divvy class Provisioner def initialize(host, target_package, server_options) @target_package = Divvy::Script::PACKAGES[target_package] raise "Package #{target_package} not found!" unless @target_package @server = Server.new(host, server_options) end attr_reader :target_package, :server def run start_time = Time.now print_package(target_package) install_plan = normalize(target_package) puts "Normalized install order: #{install_plan.map { |package| package.name }.join(', ')}" install_plan.each do |package| PackageRunner.new(server, package).process end puts "Took #{Time.now - start_time} seconds" end private # TODO: this does not prevent circular dependencies yet def normalize(package) packages = [] package.dependencies.each do |dependent| packages << normalize(dependent) # packages << package end packages << package packages.flatten.uniq end def print_package(package, depth = 1) puts "#{" " * depth}#{package.name}" package.dependencies.each do |dependent| print_package(dependent, depth + 1) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mdwan-divvy-0.1.0 | lib/divvy/provisioner.rb |
mdwan-divvy-0.1.1 | lib/divvy/provisioner.rb |
mdwan-divvy-0.1.2 | lib/divvy/provisioner.rb |