Class: Bundler::RubygemsIntegration::Future

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

Overview

Rubygems 2.0

Direct Known Subclasses

MoreFuture

Constant Summary

Constants inherited from Bundler::RubygemsIntegration

EXT_LOCK

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, #initialize, #load_path_insert_index, #loaded_gem_paths, #loaded_specs, #mark_loaded, #marshal_spec_dir, #method_visibility, #path, #platforms, #post_reset_hooks, #preserve_paths, provides?, #provides?, #read_binary, #redefine_method, #replace_bin_path, #replace_entrypoints, #replace_gem, #replace_refresh, #reset, #reverse_rubygems_kernel_mixin, #ruby_engine, #security_policies, #security_policy_keys, #set_installed_by_version, #sources, #sources=, #spec_cache_dirs, #spec_from_gem, #spec_missing_extensions?, #stub_source_index, #ui=, #undo_replacements, #user_home, #validate, version, #version, #with_build_args

Constructor Details

This class inherits a constructor from Bundler::RubygemsIntegration

Instance Method Details

#all_specsObject



656
657
658
# File 'lib/bundler/rubygems_integration.rb', line 656

def all_specs
  Gem::Specification.to_a
end

#build(spec, skip_validation = false) ⇒ Object



705
706
707
708
# File 'lib/bundler/rubygems_integration.rb', line 705

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

#download_gem(spec, uri, path) ⇒ Object



684
685
686
687
688
689
# File 'lib/bundler/rubygems_integration.rb', line 684

def download_gem(spec, uri, path)
  uri = Bundler.settings.mirror_for(uri)
  fetcher = gem_remote_fetcher
  fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
  fetcher.download(spec, uri, path)
end

#fetch_all_remote_specs(remote) ⇒ Object



675
676
677
678
679
680
681
682
# File 'lib/bundler/rubygems_integration.rb', line 675

def fetch_all_remote_specs(remote)
  source = remote.uri.is_a?(URI) ? remote.uri : URI.parse(source.to_s)

  specs = fetch_specs(source, remote, "specs")
  pres = fetch_specs(source, remote, "prerelease_specs") || []

  specs.concat(pres)
end

#fetch_specs(source, remote, name) ⇒ Object



664
665
666
667
668
669
670
671
672
673
# File 'lib/bundler/rubygems_integration.rb', line 664

def fetch_specs(source, remote, name)
  path = source + "#{name}.#{Gem.marshal_version}.gz"
  fetcher = gem_remote_fetcher
  fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
  string = 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



660
661
662
# File 'lib/bundler/rubygems_integration.rb', line 660

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

#gem_from_path(path, policy = nil) ⇒ Object



698
699
700
701
702
703
# File 'lib/bundler/rubygems_integration.rb', line 698

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

#gem_remote_fetcherObject



691
692
693
694
695
696
# File 'lib/bundler/rubygems_integration.rb', line 691

def gem_remote_fetcher
  require "resolv"
  proxy = configuration[:http_proxy]
  dns = Resolv::DNS.new
  Bundler::GemRemoteFetcher.new(proxy, dns)
end

#repository_subdirectoriesObject



710
711
712
# File 'lib/bundler/rubygems_integration.rb', line 710

def repository_subdirectories
  Gem::REPOSITORY_SUBDIRECTORIES
end

#stub_rubygems(specs) ⇒ Object



648
649
650
651
652
653
654
# File 'lib/bundler/rubygems_integration.rb', line 648

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

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