Skip to content

Instantly share code, notes, and snippets.

@reasonset
Created May 14, 2025 16:43
Show Gist options
  • Save reasonset/f6adf5cadc4bb7fa2832c63a75e267bc to your computer and use it in GitHub Desktop.
Save reasonset/f6adf5cadc4bb7fa2832c63a75e267bc to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'set'
lib = Set.new
ARGV.each do |dir|
Dir.glob("#{dir}/**/*.rb").each do |rb|
File.foreach(rb) do |line|
if line =~ /^\s*require\s+["'](.*?)["']\s*$/
lib_str = $1
break if lib_str[0, 8] == "bundler/" # Skip file using bundler.
lib.add lib_str
end
end
end
end
lib.each do |l|
begin
require l
rescue
puts l
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment