Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created June 2, 2010 22:06
Show Gist options
  • Save luislavena/423089 to your computer and use it in GitHub Desktop.
Save luislavena/423089 to your computer and use it in GitHub Desktop.
#
# Instructions:
#
# * Download Microsoft Journal Sample code February 1997:
#
# http://globalfilesearch.com/download.aspx?path=ringtail.its.monash.edu.au/pub/msj/newfiles/MSJFEB97.EXE
#
# * Extract depends.exe from 'Under the Hood' folder and place along this script.
#
# * call it with 'ruby detect.rb'
#
# NOTE: Some gems contains fat-binaries, look for 1.8/ext.so, that means it has both (1.8 and 1.9)
#
require 'rubygems'
pattern = /ruby18/
# Iterate over all gems looking for path occurrences
Gem.source_index.each do |full_name, spec|
if spec.extensions.any?
reqs = spec.require_paths.join(',')
lookout = File.join(spec.installation_path, 'gems', full_name, "{#{reqs}}", "**", "*.so")
Dir.glob(lookout).each do |ext|
output = `depends #{ext.gsub(File::SEPARATOR, File::ALT_SEPARATOR)}`
if output =~ pattern
warn "Gem #{full_name} extension '#{File.basename(File.dirname(ext))}/#{File.basename(ext)}' depends on supplied pattern."
end
end
end
spec.files.select { |f| f =~ /\.so$/ }.each do |ext|
ext = File.join(spec.installation_path, 'gems', full_name, ext)
output = `depends #{ext.gsub(File::SEPARATOR, File::ALT_SEPARATOR)}`
if output =~ pattern
warn "Gem #{full_name} extension '#{File.basename(File.dirname(ext))}/#{File.basename(ext)}' depends on supplied pattern."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment