~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/rubygems/commands/fetch_command.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
require 'rubygems/command'
2
2
require 'rubygems/local_remote_options'
3
3
require 'rubygems/version_option'
4
 
require 'rubygems/source_info_cache'
5
4
 
6
5
class Gem::Commands::FetchCommand < Gem::Command
7
6
 
36
35
    version = options[:version] || Gem::Requirement.default
37
36
    all = Gem::Requirement.default != version
38
37
 
 
38
    platform  = Gem.platforms.last
39
39
    gem_names = get_all_gem_names
40
40
 
41
41
    gem_names.each do |gem_name|
42
42
      dep = Gem::Dependency.new gem_name, version
43
43
      dep.prerelease = options[:prerelease]
44
44
 
45
 
      specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, all, true,
46
 
                                                         dep.prerelease?)
47
 
 
48
45
      specs_and_sources, errors =
49
46
        Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
50
47
                                                   dep.prerelease?)
51
48
 
 
49
      if platform then
 
50
        filtered = specs_and_sources.select { |s,| s.platform == platform }
 
51
        specs_and_sources = filtered unless filtered.empty?
 
52
      end
 
53
 
52
54
      spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
53
55
 
54
56
      if spec.nil? then
55
 
        show_lookup_failure gem_name, version, errors
 
57
        show_lookup_failure gem_name, version, errors, options[:domain]
56
58
        next
57
59
      end
58
60
 
59
61
      path = Gem::RemoteFetcher.fetcher.download spec, source_uri
60
 
      FileUtils.mv path, spec.file_name
 
62
      FileUtils.mv path, File.basename(spec.cache_file)
61
63
 
62
64
      say "Downloaded #{spec.full_name}"
63
65
    end