File: require_relative_dir.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 (13 lines) | stat: -rw-r--r-- 337 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
module Backports
  def self.require_relative_dir
    dir = caller.first.split(/\.rb:\d/,2).first
    short_path = dir[/.*(backports\/.*)/, 1] << '/'
    Dir.entries(dir).
        map{|f| Regexp.last_match(1) if /^(.*)\.rb$/ =~ f}.
        compact.
        sort.
        each do |f|
          require short_path + f
        end
  end
end