diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-30 22:10:21 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-30 22:10:21 +0000 |
commit | 310d77d4b05d1aa166616ca323ebcc7f67bc7378 (patch) | |
tree | c778eba7300c7eec523962d80f973d1ab1f18a4e /lib/rubygems/specification.rb | |
parent | d82e5cc4cc0c3340a9fa92f795751d495e13efe1 (diff) | |
download | ruby-310d77d4b05d1aa166616ca323ebcc7f67bc7378.tar.gz |
* lib/rubygems: Import RubyGems from master as of commit 523551c
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/specification.rb')
-rw-r--r-- | lib/rubygems/specification.rb | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 78f62c7a89..d2d48c8501 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -1016,25 +1016,43 @@ class Gem::Specification < Gem::BasicSpecification end ## - # Return a list of all outdated specifications. This method is HEAVY + # Return a list of all outdated local gem names. This method is HEAVY # as it must go fetch specifications from the server. + # + # Use outdated_and_latest_version if you wish to retrieve the latest remote + # version as well. def self.outdated - outdateds = [] + outdated_and_latest_version.map { |local, _| local.name } + end + + ## + # Enumerates the outdated local gems yielding the local specification and + # the latest remote version. + # + # This method may take some time to return as it must check each local gem + # against the server's index. + + def self.outdated_and_latest_version + return enum_for __method__ unless block_given? # TODO: maybe we should switch to rubygems' version service? fetcher = Gem::SpecFetcher.fetcher - latest_specs(true).each do |local| - dependency = Gem::Dependency.new local.name, ">= #{local.version}" - remotes, _ = fetcher.search_for_dependency dependency - remotes = remotes.map { |n, _| n.version } - latest = remotes.sort.last + latest_specs(true).each do |local_spec| + dependency = + Gem::Dependency.new local_spec.name, ">= #{local_spec.version}" + + remotes, = fetcher.search_for_dependency dependency + remotes = remotes.map { |n, _| n.version } - outdateds << local.name if latest and local.version < latest + latest_remote = remotes.sort.last + + yield [local_spec, latest_remote] if + latest_remote and local_spec.version < latest_remote end - outdateds + nil end ## |