Sha256: be65f23d62282e6a6623ef947467d0b80a0cd43c480e83976e0cb68e95177dee

Contents?: true

Size: 1.82 KB

Versions: 35

Compression:

Stored size: 1.82 KB

Contents

module Berkshelf
  class Resolver
    class Graph < Solve::Graph
      # @param [Berkshelf::CookbookStore] store
      def populate_store(store = nil)
        store ||= Berkshelf::CookbookStore.instance

        store.cookbooks.each do |cookbook|
          artifact(cookbook.cookbook_name, cookbook.version)

          cookbook.dependencies.each do |dependency, constraint|
            constraint = nil if constraint.empty?
            artifact(cookbook.cookbook_name, cookbook.version).depends(dependency, constraint)
          end
        end
      end

      # Add dependencies of a locally cached cookbook to the graph
      #
      # @param [Berkshelf::CachedCookbook] cookbook
      #
      # @return [Hash]
      def populate_local(cookbook)
        name    = cookbook.cookbook_name
        version = cookbook.version

        artifact(name, version)
        cookbook.dependencies.each do |dependency, constraint|
          constraint = nil if constraint.empty?
          artifact(name, version).depends(dependency, constraint)
        end
      end

      # @param [Array<Berkshelf::Source>, Berkshelf::Source] sources
      def populate(sources)
        universe(sources).each do |cookbook|
          next if has_artifact?(cookbook.name, cookbook.version)

          artifact(cookbook.name, cookbook.version)

          cookbook.dependencies.each do |dependency, constraint|
            constraint = nil if constraint.empty?
            artifact(cookbook.name, cookbook.version).depends(dependency, constraint)
          end
        end
      end

      # @param [Array<Berkshelf::Source>, Berkshelf::Source] sources
      #
      # @return [Array<Berkshelf::RemoteCookbook>]
      def universe(sources)
        cookbooks = []
        Array(sources).each { |source| cookbooks = cookbooks | source.universe }
        cookbooks
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
berkshelf-5.5.0 lib/berkshelf/resolver/graph.rb
berkshelf-5.4.0 lib/berkshelf/resolver/graph.rb
berkshelf-5.3.0 lib/berkshelf/resolver/graph.rb
berkshelf-5.2.0 lib/berkshelf/resolver/graph.rb
berkshelf-5.1.0 lib/berkshelf/resolver/graph.rb
berkshelf-5.0.0 lib/berkshelf/resolver/graph.rb
berkshelf-4.3.5 lib/berkshelf/resolver/graph.rb
berkshelf-4.3.3 lib/berkshelf/resolver/graph.rb
berkshelf-4.3.2 lib/berkshelf/resolver/graph.rb
berkshelf-4.3.1 lib/berkshelf/resolver/graph.rb
berkshelf-4.3.0 lib/berkshelf/resolver/graph.rb
berkshelf-4.2.3 lib/berkshelf/resolver/graph.rb
berkshelf-4.2.2 lib/berkshelf/resolver/graph.rb
berkshelf-4.2.1 lib/berkshelf/resolver/graph.rb
berkshelf-4.2.0 lib/berkshelf/resolver/graph.rb
berkshelf-4.1.1 lib/berkshelf/resolver/graph.rb
berkshelf-4.1.0 lib/berkshelf/resolver/graph.rb
berkshelf-4.0.1 lib/berkshelf/resolver/graph.rb
berkshelf-4.0.0 lib/berkshelf/resolver/graph.rb
berkshelf-3.3.0 lib/berkshelf/resolver/graph.rb