Class: Bundler::RubygemsIntegration::Future

Inherits:
Bundler::RubygemsIntegration show all
Defined in:
lib/bundler/rubygems_integration.rb

Overview

Rubygems 2.0

Direct Known Subclasses

MoreFuture

Instance Method Summary collapse

Methods inherited from Bundler::RubygemsIntegration

#backport_base_dir, #backport_cache_file, #backport_segment_generation, #backport_spec_file, #backport_yaml_initialize, #bin_path, #build_args, #build_args=, #build_gem, #clear_paths, #config_map, #configuration, #ext_lock, #fetch_prerelease_specs, #gem_bindir, #gem_cache, #gem_dir, #gem_path, #inflate, #loaded_specs, #mark_loaded, #marshal_spec_dir, #path, #platforms, #preserve_paths, #provides?, provides?, #read_binary, #redefine_method, #replace_bin_path, #replace_entrypoints, #replace_gem, #replace_refresh, #reverse_rubygems_kernel_mixin, #ruby_engine, #security_policies, #security_policy_keys, #sources, #sources=, #spec_cache_dirs, #spec_from_gem, #stub_source_index, #ui=, #user_home, version, #version, #with_build_args

Instance Method Details

#all_specsObject



504
505
506
# File 'lib/bundler/rubygems_integration.rb', line 504

def all_specs
  Gem::Specification.to_a
end

#build(spec, skip_validation = false) ⇒ Object



552
553
554
555
# File 'lib/bundler/rubygems_integration.rb', line 552

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

#download_gem(spec, uri, path) ⇒ Object



537
538
539
540
541
542
543
# File 'lib/bundler/rubygems_integration.rb', line 537

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

#fetch_all_remote_specsObject



521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/bundler/rubygems_integration.rb', line 521

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

#fetch_specs(source, name) ⇒ Object



512
513
514
515
516
517
518
519
# File 'lib/bundler/rubygems_integration.rb', line 512

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

#find_name(name) ⇒ Object



508
509
510
# File 'lib/bundler/rubygems_integration.rb', line 508

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

#gem_from_path(path, policy = nil) ⇒ Object



545
546
547
548
549
550
# File 'lib/bundler/rubygems_integration.rb', line 545

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

#repository_subdirectoriesObject



557
558
559
# File 'lib/bundler/rubygems_integration.rb', line 557

def repository_subdirectories
  Gem::REPOSITORY_SUBDIRECTORIES
end

#stub_rubygems(specs) ⇒ Object



496
497
498
499
500
501
502
# File 'lib/bundler/rubygems_integration.rb', line 496

def stub_rubygems(specs)
  Gem::Specification.all = specs

  Gem.post_reset do
    Gem::Specification.all = specs
  end
end