Created
November 21, 2014 20:24
-
-
Save chetan/8cb79727674056109d7a to your computer and use it in GitHub Desktop.
List all runtime dependencies for the given gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
target = ARGV.shift.strip | |
class App | |
def initialize | |
@deps = [] | |
end | |
def resolve(gem) | |
if @deps.include? gem or gem.strip.empty? then | |
return | |
end | |
# puts "resolving: " + gem | |
@deps << gem | |
# cmd = "gem dependency " + gem + " | egrep -v ^Gem | egrep -v 'development\\)$' | awk '{print $1}'" | |
# gems = `#{cmd}` | |
# gems.strip.split(/\n/).each { |g| resolve(g) } | |
specs = Gem::Dependency.new(gem).matching_specs | |
return if !specs or specs.empty? | |
specs.first.dependencies.each do |d| | |
next if d.type == :development | |
resolve(d.name) | |
end | |
return @deps | |
end | |
end | |
puts "listing all runtime dependencies for #{target}" | |
puts App.new.resolve(target).sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment