method

select_spec

ruby latest stable - Class: Bundler::CLI::Common

Method not available on this version

This method is only available on newer versions. The first available version (v2_6_3) is shown here.

select_spec(name, regex_match = nil)
public

No documentation available.

# File lib/bundler/cli/common.rb, line 30
    def self.select_spec(name, regex_match = nil)
      specs = []
      regexp = Regexp.new(name) if regex_match

      Bundler.definition.specs.each do |spec|
        return spec if spec.name == name
        specs << spec if regexp && spec.name =~ regexp
      end

      case specs.count
      when 0
        raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
      when 1
        specs.first
      else
        ask_for_spec_from(specs)
      end
    rescue RegexpError
      raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
    end