Module: Backports::StdLib

Defined in:
lib/vendor/backports-3.3.5/lib/backports/tools.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.



63
64
65
# File 'lib/vendor/backports-3.3.5/lib/backports/tools.rb', line 63

def extended_lib
  @extended_lib
end

Class Method Details

.extend_relative(relative_dir = "stdlib") ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vendor/backports-3.3.5/lib/backports/tools.rb', line 65

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