Class: Bundler::SpecSet (Ruby 2.7.5)
Description: Class : Bundler::SpecSet - Ruby 2.7.5

### Home Classes Methods

### In Files

- bundler/spec_set.rb

### Parent

Object

### Methods

- ::new
- #<<
- #[]
- #[]=
- #each
- #empty?
- #find_by_name_and_platform
- #for
- #length
- #materialize
- #materialized_for_all_platforms
- #merge
- #size
- #sort!
- #to_a
- #to_hash
- #valid_for?
- #what_required

### Included Modules

- Enumerable
- TSort

### Class/Module Index

Quicksearch

- AmbiguousCommandError
- AmbiguousTaskError
- Bundler
- Bundler::APIResponseMismatchError
- Bundler::BuildMetadata
- Bundler::BundlerError
- Bundler::CLI
- Bundler::CLI::Add
- Bundler::CLI::Binstubs
- Bundler::CLI::Cache
- Bundler::CLI::Check
- Bundler::CLI::Clean
- Bundler::CLI::Common
- Bundler::CLI::Config
- Bundler::CLI::Config::Base
- Bundler::CLI::Console
- Bundler::CLI::Doctor
- Bundler::CLI::Exec
- Bundler::CLI::Gem
- Bundler::CLI::Info
- Bundler::CLI::Init
- Bundler::CLI::Inject
- Bundler::CLI::Install
- Bundler::CLI::Issue
- Bundler::CLI::List
- Bundler::CLI::Lock
- Bundler::CLI::Open
- Bundler::CLI::Outdated
- Bundler::CLI::Package
- Bundler::CLI::Platform
- Bundler::CLI::Plugin
- Bundler::CLI::Pristine
- Bundler::CLI::Remove
- Bundler::CLI::Show
- Bundler::CLI::Update
- Bundler::CLI::Viz
- Bundler::CompactIndexClient
- Bundler::CompactIndexClient::Cache
- Bundler::CompactIndexClient::Error
- Bundler::CompactIndexClient::Updater
- Bundler::CompactIndexClient::Updater::MisMatchedChecksumError
- Bundler::ConnectionPool
- Bundler::ConnectionPool::Error
- Bundler::ConnectionPool::PoolShuttingDownError
- Bundler::ConnectionPool::TimedStack
- Bundler::ConnectionPool::Wrapper
- Bundler::CurrentRuby
- Bundler::CyclicDependencyError
- Bundler::Definition
- Bundler::DepProxy
- Bundler::Dependency
- Bundler::Deployment
- Bundler::Deprecate
- Bundler::DeprecatedError
- Bundler::Dsl
- Bundler::Dsl::DSLError
- Bundler::EndpointSpecification
- Bundler::Env
- Bundler::EnvironmentPreserver
- Bundler::FeatureFlag
- Bundler::Fetcher
- Bundler::Fetcher::AuthenticationRequiredError
- Bundler::Fetcher::BadAuthenticationError
- Bundler::Fetcher::Base
- Bundler::Fetcher::CertificateFailureError
- Bundler::Fetcher::CompactIndex
- Bundler::Fetcher::Dependency
- Bundler::Fetcher::Downloader
- Bundler::Fetcher::FallbackError
- Bundler::Fetcher::Index
- Bundler::Fetcher::NetworkDownError
- Bundler::Fetcher::SSLError
- Bundler::Fetcher::TooManyRequestsError
- Bundler::FileUtils
- Bundler::FileUtils::DryRun
- Bundler::FileUtils::NoWrite
- Bundler::FileUtils::StreamUtils_
- Bundler::FileUtils::Verbose
- Bundler::FriendlyErrors
- Bundler::GemHelper
- Bundler::GemHelpers
- Bundler::GemHelpers::PlatformMatch
- Bundler::GemInstaller
- Bundler::GemNotFound
- Bundler::GemRemoteFetcher
- Bundler::GemRequireError
- Bundler::GemVersionPromoter
- Bundler::Gemdeps
- Bundler::GemfileError
- Bundler::GemfileEvalError
- Bundler::GemfileLockNotFound
- Bundler::GemfileNotFound
- Bundler::GemspecError
- Bundler::GenericSystemCallError
- Bundler::GitError
- Bundler::Graph
- Bundler::Graph::GraphVizClient
- Bundler::HTTPError
- Bundler::Index
- Bundler::Injector
- Bundler::InstallError
- Bundler::InstallHookError
- Bundler::Installer
- Bundler::InvalidOption
- Bundler::LazySpecification
- Bundler::LazySpecification::Identifier
- Bundler::LockfileError
- Bundler::LockfileGenerator
- Bundler::LockfileParser
- Bundler::MarshalError
- Bundler::MatchPlatform
- Bundler::MirrorSockets
- Bundler::Molinillo
- Bundler::Molinillo::CircularDependencyError
- Bundler::Molinillo::Compatibility
- Bundler::Molinillo::Delegates
- Bundler::Molinillo::Delegates::ResolutionState
- Bundler::Molinillo::Delegates::SpecificationProvider
- Bundler::Molinillo::DependencyGraph
- Bundler::Molinillo::DependencyGraph::Action
- Bundler::Molinillo::DependencyGraph::AddEdgeNoCircular
- Bundler::Molinillo::DependencyGraph::DeleteEdge
- Bundler::Molinillo::DependencyGraph::DetachVertexNamed
- Bundler::Molinillo::DependencyGraph::Log
- Bundler::Molinillo::DependencyGraph::Tag
- Bundler::Molinillo::DependencyGraph::Vertex
- Bundler::Molinillo::DependencyState
- Bundler::Molinillo::NoSuchDependencyError
- Bundler::Molinillo::PossibilityState
- Bundler::Molinillo::ResolutionState
- Bundler::Molinillo::Resolver
- Bundler::Molinillo::Resolver::Resolution
- Bundler::Molinillo::Resolver::Resolution::Conflict
- Bundler::Molinillo::Resolver::Resolution::PossibilitySet
- Bundler::Molinillo::Resolver::Resolution::UnwindDetails
- Bundler::Molinillo::ResolverError
- Bundler::Molinillo::SpecificationProvider
- Bundler::Molinillo::UI
- Bundler::Molinillo::VersionConflict
- Bundler::NoSpaceOnDeviceError
- Bundler::OperationNotSupportedError
- Bundler::ParallelInstaller
- Bundler::ParallelInstaller::SpecInstallation
- Bundler::PathError
- Bundler::PermissionError
- Bundler::Persistent
- Bundler::Persistent::Net
- Bundler::Persistent::Net::HTTP
- Bundler::Persistent::Net::HTTP::Persistent
- Bundler::Persistent::Net::HTTP::Persistent::Error
- Bundler::PersistentHTTP
- Bundler::Plugin
- Bundler::Plugin::API
- Bundler::Plugin::API::Source
- Bundler::Plugin::DSL
- Bundler::Plugin::DSL::PluginGemfileError
- Bundler::Plugin::Events
- Bundler::Plugin::Index
- Bundler::Plugin::Index::CommandConflict
- Bundler::Plugin::Index::SourceConflict
- Bundler::Plugin::Installer
- Bundler::Plugin::Installer::Git
- Bundler::Plugin::Installer::Rubygems
- Bundler::Plugin::MalformattedPlugin
- Bundler::Plugin::SourceList
- Bundler::Plugin::UndefinedCommandError
- Bundler::Plugin::UnknownSourceError
- Bundler::PluginError
- Bundler::ProcessLock
- Bundler::ProductionError
- Bundler::RemoteSpecification
- Bundler::Resolver
- Bundler::Resolver::SpecGroup
- Bundler::Retry
- Bundler::RubyDsl
- Bundler::RubyGemsGemInstaller
- Bundler::RubyVersion
- Bundler::RubyVersionMismatch
- Bundler::RubygemsIntegration
- Bundler::RubygemsIntegration::Gem
- Bundler::Runtime
- Bundler::SecurityError
- Bundler::Settings
- Bundler::Settings::Mirror
- Bundler::Settings::MirrorConfig
- Bundler::Settings::Mirrors
- Bundler::Settings::TCPSocketProbe
- Bundler::Settings::Validator
- Bundler::Settings::Validator::Rule
- Bundler::SharedHelpers
- Bundler::SimilarityDetector
- Bundler::SocketAddress
- Bundler::Source
- Bundler::Source::Gemspec
- Bundler::Source::Git
- Bundler::Source::Git::GitCommandError
- Bundler::Source::Git::GitNotAllowedError
- Bundler::Source::Git::GitNotInstalledError
- Bundler::Source::Git::GitProxy
- Bundler::Source::Git::MissingGitRevisionError
- Bundler::Source::Metadata
- Bundler::Source::Path
- Bundler::Source::Path::Installer
- Bundler::Source::Rubygems
- Bundler::Source::Rubygems::Remote
- Bundler::SourceList
- Bundler::SpecSet
- Bundler::Standalone
- Bundler::StubSpecification
- Bundler::SudoNotPermittedError
- Bundler::TemporaryResourceError
- Bundler::Thor::Actions
- Bundler::Thor::Actions::CapturableERB
- Bundler::Thor::Actions::ClassMethods
- Bundler::Thor::Base
- Bundler::Thor::Base::ClassMethods
- Bundler::Thor::Command
- Bundler::Thor::CoreExt
- Bundler::Thor::CoreExt::OrderedHash
- Bundler::Thor::DynamicCommand
- Bundler::Thor::DynamicTask
- Bundler::Thor::Group
- Bundler::Thor::HiddenCommand
- Bundler::Thor::HiddenTask
- Bundler::Thor::Invocation
- Bundler::Thor::Invocation::ClassMethods
- Bundler::Thor::LineEditor
- Bundler::Thor::LineEditor::Basic
- Bundler::Thor::LineEditor::Readline
- Bundler::Thor::LineEditor::Readline::PathCompletion
- Bundler::Thor::NestedContext
- Bundler::Thor::RakeCompat
- Bundler::Thor::Shell
- Bundler::Thor::Shell::Basic
- Bundler::Thor::Shell::Color
- Bundler::Thor::Shell::HTML
- Bundler::Thor::Task
- Bundler::Thor::Util
- Bundler::ThreadCreationError
- Bundler::UI
- Bundler::UI::RGProxy
- Bundler::UI::Shell
- Bundler::UI::Silent
- Bundler::URI
- Bundler::URI::BadURIError
- Bundler::URI::Error
- Bundler::URI::Escape
- Bundler::URI::FTP
- Bundler::URI::File
- Bundler::URI::Generic
- Bundler::URI::HTTP
- Bundler::URI::HTTPS
- Bundler::URI::InvalidComponentError
- Bundler::URI::InvalidURIError
- Bundler::URI::LDAP
- Bundler::URI::LDAPS
- Bundler::URI::MailTo
- Bundler::URI::Parser
- Bundler::URI::REGEXP
- Bundler::URI::RFC2396_Parser
- Bundler::URI::RFC2396_REGEXP
- Bundler::URI::RFC2396_REGEXP::PATTERN
- Bundler::URICredentialsFilter
- Bundler::VersionConflict
- Bundler::VersionRanges
- Bundler::VersionRanges::ReqR
- Bundler::VirtualProtocolError
- Bundler::Worker
- Bundler::Worker::WrappedException
- Bundler::YAMLSerializer
- Bundler::YamlSyntaxError
- Error
- Gem
- Gem::Dependency
- Gem::Platform
- Gem::Specification
- InvocationError
- Kernel
- MalformattedArgumentError
- Object
- RequiredArgumentMissingError
- UndefinedCommandError
- UndefinedCommandError::SpellChecker
- UndefinedTaskError
- UnknownArgumentError
- UnknownArgumentError::SpellChecker

No matching classes.

# Bundler::SpecSet

### Public Class Methods

new(specs) click to toggle source

                   # File bundler/spec_set.rb, line 11
    def initialize(specs)
      @specs = specs
    end

### Public Instance Methods

<<(spec) click to toggle source

                   # File bundler/spec_set.rb, line 130
    def <<(spec)
      @specs << spec
    end

[](key) click to toggle source

                   # File bundler/spec_set.rb, line 54
    def [](key)
      key = key.name if key.respond_to?(:name)
      lookup[key].reverse
    end

[]=(key, value) click to toggle source

                   # File bundler/spec_set.rb, line 59
    def []=(key, value)
      @specs << value
      @lookup = nil
      @sorted = nil
    end

each(&b) click to toggle source

                   # File bundler/spec_set.rb, line 146
    def each(&b)
      sorted.each(&b)
    end

empty?() click to toggle source

                   # File bundler/spec_set.rb, line 142
    def empty?
      @specs.empty?
    end

find_by_name_and_platform(name, platform) click to toggle source

                   # File bundler/spec_set.rb, line 119
    def find_by_name_and_platform(name, platform)
      @specs.detect {|spec| spec.name == name && spec.match_platform(platform) }
    end

for(dependencies, skip = [], check = false, match_current_platform = false, raise_on_missing = true) click to toggle source

                   # File bundler/spec_set.rb, line 15
    def for(dependencies, skip = [], check = false, match_current_platform = false, raise_on_missing = true)
      handled = Set.new
      deps = dependencies.dup
      specs = []
      skip += ["bundler"]

      loop do
        break unless dep = deps.shift
        next if !handled.add?(dep) || skip.include?(dep.name)

        if spec = spec_for_dependency(dep, match_current_platform)
          specs << spec

          spec.dependencies.each do |d|
            next if d.type == :development
            d = DepProxy.new(d, dep.__platform) unless match_current_platform
            deps << d
          end
        elsif check
          return false
        elsif raise_on_missing
          others = lookup[dep.name] if match_current_platform
          message = "Unable to find a spec satisfying #{dep} in the set. Perhaps the lockfile is corrupted?"
          message += " Found #{others.join(", ")} that did not match the current platform." if others && !others.empty?
          raise GemNotFound, message
        end
      end

      if spec = lookup["bundler"].first
        specs << spec
      end

      check ? true : SpecSet.new(specs)
    end

length() click to toggle source

                   # File bundler/spec_set.rb, line 134
    def length
      @specs.length
    end

materialize(deps, missing_specs = nil) click to toggle source

                   # File bundler/spec_set.rb, line 77
    def materialize(deps, missing_specs = nil)
      materialized = self.for(deps, [], false, true, !missing_specs).to_a
      deps = materialized.map(&:name).uniq
      materialized.map! do |s|
        next s unless s.is_a?(LazySpecification)
        s.source.dependency_names = deps if s.source.respond_to?(:dependency_names=)
        spec = s.__materialize__
        unless spec
          unless missing_specs
            raise GemNotFound, "Could not find #{s.full_name} in any of the sources"
          end
          missing_specs << s
        end
        spec
      end
      SpecSet.new(missing_specs ? materialized.compact : materialized)
    end

materialized_for_all_platforms() click to toggle source

Materialize for all the specs in the spec set, regardless of what platform they're for This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform) @return [Array<Gem::Specification>]

                   # File bundler/spec_set.rb, line 98
    def materialized_for_all_platforms
      names = @specs.map(&:name).uniq
      @specs.map do |s|
        next s unless s.is_a?(LazySpecification)
        s.source.dependency_names = names if s.source.respond_to?(:dependency_names=)
        spec = s.__materialize__
        raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
        spec
      end
    end

merge(set) click to toggle source

                   # File bundler/spec_set.rb, line 109
    def merge(set)
      arr = sorted.dup
      set.each do |set_spec|
        full_name = set_spec.full_name
        next if arr.any? {|spec| spec.full_name == full_name }
        arr << set_spec
      end
      SpecSet.new(arr)
    end

size() click to toggle source

                   # File bundler/spec_set.rb, line 138
    def size
      @specs.size
    end

sort!() click to toggle source

                   # File bundler/spec_set.rb, line 65
    def sort!
      self
    end

to_a() click to toggle source

                   # File bundler/spec_set.rb, line 69
    def to_a
      sorted.dup
    end

to_hash() click to toggle source

                   # File bundler/spec_set.rb, line 73
    def to_hash
      lookup.dup
    end

valid_for?(deps) click to toggle source

                   # File bundler/spec_set.rb, line 50
    def valid_for?(deps)
      self.for(deps, [], true)
    end

what_required(spec) click to toggle source

                   # File bundler/spec_set.rb, line 123
    def what_required(spec)
      unless req = find {|s| s.dependencies.any? {|d| d.type == :runtime && d.name == spec.name } }
        return [spec]
      end
      what_required(req) << spec
    end