File: std_lib.rb

package info (click to toggle)
ruby-backports 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,460 kB
  • ctags: 703
  • sloc: ruby: 6,195; makefile: 24
file content (24 lines) | stat: -rw-r--r-- 775 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Will intercept future and past 'require' calls of std_lib
# and load additionally the updated libraries.
require 'backports/tools/std_lib'
require 'backports/tools/alias_method_chain'

module Kernel
  def require_with_backports(lib)
    begin
      return false unless require_without_backports(lib)
      paths = Backports::StdLib.extended_lib.fetch(lib, nil)
    rescue LoadError
      return false if Backports::StdLib::LoadedFeatures.new.include?(lib)
      raise unless paths = Backports::StdLib.extended_lib.fetch(lib, nil)
      Backports::StdLib::LoadedFeatures.mark_as_loaded(lib)
    end
    if paths
      paths.each do |path|
        require_without_backports(path)
      end
    end
    true
  end
  Backports.alias_method_chain self, :require, :backports
end