Skip to content
Browse files

Include gem versions in output if the option is enabled

  • Loading branch information...
1 parent d8a4f95 commit dc5fed2bbadded9f3e7355df2697b8abe0c0daae Christopher Patuzzo committed
Showing with 9 additions and 8 deletions.
  1. +3 −2 lib/rubygems/commands/dependent_command.rb
  2. +5 −5 lib/rubygems/dependent.rb
  3. +1 −1 spec/dependent_spec.rb
View
5 lib/rubygems/commands/dependent_command.rb
@@ -40,11 +40,12 @@ def execute
gem = get_all_gem_names.first
gems_and_dependencies = Gem::Dependent.find(gem, options)
- gems_and_dependencies.each do |gem, dependencies|
+ gems_and_dependencies.each do |gem, version, dependencies|
requirements = dependencies.map do |dependency|
formatted_dependency(dependency)
end.join(', ')
- puts "#{gem} #{requirements}"
+ version = options[:all_versions] ? " (v#{version})" : nil
+ puts "#{gem}#{version} #{requirements}"
end
rescue Object => e
$stderr.puts e
View
10 lib/rubygems/dependent.rb
@@ -33,9 +33,9 @@ def self.fetch_all_dependencies(specs_and_sources, options)
parallel = (options[:parallel] || 15)
Gem::Dependent::Parallel.map(specs_and_sources, :in_processes => parallel) do |spec, source|
yield if block_given?
- name = spec.first
dependencies = fetch_dependencies(spec, source)
- [name, dependencies]
+ name, version = spec[0,2]
+ [name, version, dependencies]
end
end
@@ -50,10 +50,10 @@ def self.fetch_dependencies(spec, source)
end
def self.select_dependent(gems_and_dependencies, gem)
- gems_and_dependencies.map do |name, dependencies|
- matching_dependencies = dependencies.select{|d| d.name == gem }
+ gems_and_dependencies.map do |name, version, dependencies|
+ matching_dependencies = dependencies.select{|d| d.name == gem } rescue []
next if matching_dependencies.empty?
- [name, matching_dependencies]
+ [name, version, matching_dependencies]
end.compact
end
View
2 spec/dependent_spec.rb
@@ -24,7 +24,7 @@
}
def simplify(dependencies)
- dependencies.map{|name, deps| [name, deps.map{|d| d.name}] }
+ dependencies.map{|name, version, deps| [name, deps.map{|d| d.name}] }
end
def stub_source(gem_source = nil, check_against_fixtures = true)

0 comments on commit dc5fed2

Please sign in to comment.
Something went wrong with that request. Please try again.