rubygems/rubygems — Issue #252: Find requireable file
Author: trans
Created: 2012-01-03 16:36:25+00:00
State: open

Found this useful for looking into a gem to see if a file is requireable from it.

```ruby
module Gem
class Specification

# Return full path of requireable file given relative path if it exists, otherwise nil.
def find_requireable_file(file)
root = full_gem_path
require_paths.each do |lib|
base = File.join(root, lib, file)
Gem.suffixes.each do |suf|
path = "#{base}#{suf}"
return path if File.file? path
end
end
return nil
end

end
end
```

Is there a current/better way to do this? If not then maybe this could be added to RubyGems (maybe with a better method name) or something akin to it?