Sha256: 7f21c1ee0cd7c3c9e54fc2aeb49dea57b9b2ae3a814c582871513559df8d04a9

Contents?: true

Size: 1.18 KB

Versions: 14

Compression:

Stored size: 1.18 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] = deps
      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

14 entries across 14 versions & 2 rubygems

Version Path
rubygems-update-3.4.6 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
bundler-2.4.6 lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
rubygems-update-3.4.5 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
bundler-2.4.5 lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
rubygems-update-3.4.4 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
bundler-2.4.4 lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
rubygems-update-3.4.3 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
bundler-2.4.3 lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
rubygems-update-3.4.2 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
bundler-2.4.2 lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
rubygems-update-3.4.1 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
bundler-2.4.1 lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
rubygems-update-3.4.0 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
bundler-2.4.0 lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb