Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Gem.find_files
(::String glob, ?::boolish check_load_path) -> ::Array[::String]
find_files(glob, check_load_path=true)
lib/rubygems.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/rubygems.rb, line 492
def self.find_files(glob, check_load_path=true)
files = []
files = find_files_from_load_path glob if check_load_path
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs
files.concat gem_specifications.flat_map {|spec|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
}
# $LOAD_PATH might contain duplicate entries or reference
# the spec dirs directly, so we prune.
files.uniq! if check_load_path
files
end
Returns a list of paths matching glob that can be used by a gem to pick up features from other gems. For example:
Example
Gem.find_files('rdoc/discover').each do |path| load path end
if check_load_path is true (the default), then find_files also searches $LOAD_PATH for files as well as gems.
Note that find_files will return all files even if they are from different versions of the same gem. See also find_latest_files
See also
.find_default_spec
.find_home
.find_config_file
.find_latest_files
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0