class Bundler::RubygemsIntegration::Future

Rubygems 2.0

def all_specs

def all_specs
  Gem::Specification.to_a
end

def build(spec, skip_validation = false)

def build(spec, skip_validation = false)
  require 'rubygems/package'
  Gem::Package.build(spec, skip_validation)
end

def download_gem(spec, uri, path)

def download_gem(spec, uri, path)
  require 'resolv'
  uri = Bundler::Source.mirror_for(uri)
  proxy, dns = configuration[:http_proxy], Resolv::DNS.new
  fetcher = Gem::RemoteFetcher.new(proxy, dns)
  fetcher.download(spec, uri, path)
end

def fetch_all_remote_specs

def fetch_all_remote_specs
  # Since SpecFetcher now returns NameTuples, we just fetch directly
  # and unmarshal the array ourselves.
  hash = {}
  Gem.sources.each do |source|
    source = URI.parse(source.to_s) unless source.is_a?(URI)
    hash[source] = fetch_specs(source, "specs")
    pres = fetch_specs(source, "prerelease_specs")
    hash[source].push(*pres) if pres && !pres.empty?
  end
  hash
end

def fetch_specs(source, name)

def fetch_specs(source, name)
  path = source + "#{name}.#{Gem.marshal_version}.gz"
  string = Gem::RemoteFetcher.fetcher.fetch_path(path)
  Bundler.load_marshal(string)
rescue Gem::RemoteFetcher::FetchError => e
  # it's okay for prerelease to fail
  raise e unless name == "prerelease_specs"
end

def find_name(name)

def find_name(name)
  Gem::Specification.find_all_by_name name
end

def gem_from_path(path, policy = nil)

def gem_from_path(path, policy = nil)
  require 'rubygems/package'
  p = Gem::Package.new(path)
  p.security_policy = policy if policy
  return p
end

def stub_rubygems(specs)

def stub_rubygems(specs)
  Gem::Specification.all = specs
  Gem.post_reset {
    Gem::Specification.all = specs
  }
end