module Bundler::CLI::Common
def self.select_spec(name, regex_match = nil)
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 dep_in_other_group = Bundler.definition.current_dependencies.find {|dep|dep.name == name } if dep_in_other_group raise GemNotFound, "Could not find gem '#{name}', because it's in the #{verbalize_groups(dep_in_other_group.groups)}, configured to be ignored." else raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies) end when 1 specs.first else ask_for_spec_from(specs) end rescue RegexpError raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies) end