module Backports::StdLib

def extend_relative relative_dir="stdlib"

def extend_relative relative_dir="stdlib"
  loaded = Backports::StdLib::LoadedFeatures.new
  dir = File.expand_path(relative_dir, File.dirname(caller.first.split(/:\d/,2).first))
  Dir.entries(dir).
    map{|f| Regexp.last_match(1) if /^(.*)\.rb$/ =~ f}.
    compact.
    each do |f|
      path = File.expand_path(f, dir)
      if loaded.include?(f)
        require path
      else
        @extended_lib[f] << path
      end
    end
end