Module: FastGem
Instance Method Summary collapse
-
#find(name) ⇒ Object
Try ro find the file “name” in any of the available paths, and return the path.
- #gem_paths ⇒ Object
- #load(name) ⇒ Object
Instance Method Details
#find(name) ⇒ Object
Try ro find the file “name” in any of the available paths, and return the path
40 41 42 43 44 45 46 47 48 |
# File 'lib/fast_gem.rb', line 40 def find(name) # look into each gempath for a matching file, sort by version (roughly), # and return the last hit gem_paths. map { |gem_path| Dir.glob("#{gem_path}/gems/#{name}-[0-9]*") }. flatten. sort_by { |gem_path| gem_path.gsub(/.*\/gems\/[^-]+-/, "") }. last end |
#gem_paths ⇒ Object
34 35 36 |
# File 'lib/fast_gem.rb', line 34 def gem_paths [ Gem.default_dir, Gem.user_dir ] end |
#load(name) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/fast_gem.rb', line 50 def load(name) path = find(name) # STDERR.puts "Load #{name} from #{path}" $: << "#{path}/lib" require name end |