Sha256: 1c540aa7dba9f20b6aa30f812230d2fe1d097935950177a9943c77586f56958f

Contents?: true

Size: 1.44 KB

Versions: 124

Compression:

Stored size: 1.44 KB

Contents

require_relative 'package'
require_relative 'version_constraint'
require_relative 'incompatibility'
require_relative 'basic_package_source'

module Bundler::PubGrub
  class StaticPackageSource < BasicPackageSource
    class DSL
      def initialize(packages, root_deps)
        @packages = packages
        @root_deps = root_deps
      end

      def root(deps:)
        @root_deps.update(deps)
      end

      def add(name, version, deps: {})
        version = Gem::Version.new(version)
        @packages[name] ||= {}
        raise ArgumentError, "#{name} #{version} declared twice" if @packages[name].key?(version)
        @packages[name][version] = clean_deps(name, version, deps)
      end

      private

      # Exclude redundant self-referencing dependencies
      def clean_deps(name, version, deps)
        deps.reject {|dep_name, req| name == dep_name && Bundler::PubGrub::RubyGems.parse_range(req).include?(version) }
      end
    end

    def initialize
      @root_deps = {}
      @packages = {}

      yield DSL.new(@packages, @root_deps)

      super()
    end

    def all_versions_for(package)
      @packages[package].keys
    end

    def root_dependencies
      @root_deps
    end

    def dependencies_for(package, version)
      @packages[package][version]
    end

    def parse_dependency(package, dependency)
      return false unless @packages.key?(package)

      Bundler::PubGrub::RubyGems.parse_constraint(package, dependency)
    end
  end
end

Version data entries

124 entries across 124 versions & 4 rubygems

Version Path
harbr-0.1.61 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.60 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.59 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.58 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.57 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.54 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.53 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.52 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.47 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb