Module: Gem

Defined in:
lib/vv/gem_methods.rb

Class Method Summary collapse

Class Method Details

.require_files(pattern, dirname: nil) ⇒ Object

dirname is almost always __dir__



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vv/gem_methods.rb', line 4

def require_files pattern, dirname: nil
  dirname ||= \
  File.dirname caller_locations[0].path

  glob = File.join dirname, pattern
  Gem.find_files(glob).each do |filepath|
    start = dirname.size + 1
    ruby_require_path = filepath[start..-1]

    if block_given?
      yield ruby_require_path
    else
      require ruby_require_path
    end
  end

end