Module: Backports::StdLib

Defined in:
lib/backports/tools/std_lib.rb

Defined Under Namespace

Classes: LoadedFeatures

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.extended_libObject

Returns the value of attribute extended_lib.



39
40
41
# File 'lib/backports/tools/std_lib.rb', line 39

def extended_lib
  @extended_lib
end

Class Method Details

.extend_relative(relative_dir = "stdlib") ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/backports/tools/std_lib.rb', line 41

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