Skip to content

Instantly share code, notes, and snippets.

@h-lame
Created March 30, 2011 11:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-lame/894223 to your computer and use it in GitHub Desktop.
Save h-lame/894223 to your computer and use it in GitHub Desktop.
require 'rubygems'
fetcher = Gem::SpecFetcher.fetcher
my_dep = 'activesupport'
# 1st arg = all (true to get all versions, false to get latest)
# 2nd arg = prerelase (true to get pre-release gems, false to get stable)
all_gems = fetcher.list(false, false)
my_deps = []
all_gems.each do |uri, gems|
gems.each do |gem|
begin
spec = fetcher.fetch_spec gem, uri
my_deps << [gem, uri] if (spec.runtime_dependencies + spec.dependencies).any? {|d| d.name == my_dep}
ensure
# urr something borked with this gemspec
end
end
end
require 'rubygems/commands/query_command'
Gem::Commands::QueryCommand.new.send(:output_query_results, my_deps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment