Top Level Namespace

Defined Under Namespace

Modules: ImageRuby, RubyImage Classes: Object

Instance Method Summary collapse

Instance Method Details

#auto_require(prefix) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/imageruby/abstract/auto_require.rb', line 23

def auto_require(prefix)
  # in Ruby 2.0 it appears Gem.source_index was removed. 
  # The same functionality can be found using Gem::Specification
  if defined?(Gem::Specification) && Gem::Specification.respond_to?(:each)
    Gem::Specification.each do |entry|
      if entry.name =~ prefix
        require entry.name
      end
    end
  else
    Gem.source_index.each do |entry|
      if entry[0] =~ prefix
        require entry[1].name
      end
    end
  end
end