Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a new option: --all-versions

  • Loading branch information...
commit d8a4f95841f267d5ece05bfde41e8c2e172a9a2c 1 parent 8c0bf32
Christopher Patuzzo authored
View
4 lib/rubygems/commands/dependent_command.rb
@@ -19,6 +19,10 @@ def initialize
add_option('--parallel N', Integer, 'Make N requests in parallel') do |n, _|
options[:parallel] = n
end
+
+ add_option('--all-versions', 'Check against all versions of gems') do
+ options[:all_versions] = true
+ end
end
def arguments
View
6 lib/rubygems/dependent.rb
@@ -8,7 +8,7 @@ class Dependent
def self.find(gem, options={})
# get all gems
specs_and_sources = with_changed_gem_source(options[:source]) do
- all_specs_and_sources
+ all_specs_and_sources(options[:all_versions])
end
if options[:fetch_limit]
@@ -62,14 +62,14 @@ def self.print_dot
$stderr.flush if rand(20) == 0 # make progress visible
end
- def self.all_specs_and_sources
+ def self.all_specs_and_sources(all_versions = false)
fetcher = Gem::SpecFetcher.fetcher
all = true
matching_platform = false
prerelease = false
matcher = Gem::Dependency.new(//, Gem::Requirement.default) # any name, any version
specs_and_sources = fetcher.find_matching matcher, all, matching_platform, prerelease
- uniq_by(specs_and_sources){|a| a.first.first }
+ all_versions ? specs_and_sources : uniq_by(specs_and_sources){|a| a.first.first }
end
# get unique elements from an array (last found is used)
View
12 spec/dependent_spec.rb
@@ -27,9 +27,11 @@ def simplify(dependencies)
dependencies.map{|name, deps| [name, deps.map{|d| d.name}] }
end
- def stub_source(gem_source = nil)
+ def stub_source(gem_source = nil, check_against_fixtures = true)
gem_source ||= 'http://gemcutter.org'
- Gem::SpecFetcher.fetcher.should_receive(:load_specs).with(URI.parse(gem_source), 'specs').and_return(fixture)
+ if check_against_fixtures
+ Gem::SpecFetcher.fetcher.should_receive(:load_specs).with(URI.parse(gem_source), 'specs').and_return(fixture)
+ end
Gem.sources = [gem_source]
end
@@ -57,6 +59,12 @@ def stub_source(gem_source = nil)
Gem::Dependent.find('hoe', :parallel => 3)
end
+ it "obeys all versions option" do
+ stub_source(nil, false)
+ Gem::Dependent.should_receive(:all_specs_and_sources).with(true)
+ Gem::Dependent.find('hoe', :all_versions => true)
+ end
+
it "has a VERSION" do
Gem::Dependent::VERSION.should =~ /^\d+\.\d+\.\d+$/
end
Please sign in to comment.
Something went wrong with that request. Please try again.