Skip to content

Instantly share code, notes, and snippets.

@regularfry
Created March 21, 2014 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regularfry/9685345 to your computer and use it in GitHub Desktop.
Save regularfry/9685345 to your computer and use it in GitHub Desktop.
microgems
# encoding: utf-8
# Smallest possible gem loader that might ever work.
# Assumes one version of each gem per $GEM_PATH, to go with link-gems.
# Assumes that the only code you want to require is in lib/.
# Only patches $LOAD_PATH, doesn't touch #require.
module Microgems
def self.setup( gem_path, load_path )
lib_glob = File.join( gem_path, "gems", "*", "lib" )
Dir[lib_glob].each do |lib_path|
load_path << lib_path
end
end
end
Microgems.setup( ENV.fetch('GEM_PATH',"").split(":").first,
$LOAD_PATH )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment