Class: Droonga::PluginLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/plugin_loader.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name) ⇒ PluginLoader

Returns a new instance of PluginLoader.



45
46
47
48
# File 'lib/droonga/plugin_loader.rb', line 45

def initialize(type, name)
  @type = type
  @name = name
end

Class Method Details

.load_allObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/droonga/plugin_loader.rb', line 23

def load_all
  $LOAD_PATH.each do |load_path|
    Dir.glob("#{load_path}/droonga/plugin/*") do |type_path|
      next unless File.directory?(type_path)
      type = File.basename(type_path)
      Dir.glob("#{type_path}/*.rb") do |path|
        name = File.basename(path, ".rb")
        loader = new(type, name)
        loader.load
      end
    end

    Pathname.glob("#{load_path}/droonga/plugins/*.rb") do |plugin_path|
      relative_plugin_path =
        plugin_path.relative_path_from(Pathname(load_path))
      require_path = relative_plugin_path.to_s.gsub(/\.rb\z/, "")
      require require_path
    end
  end
end

Instance Method Details

#loadObject



50
51
52
53
# File 'lib/droonga/plugin_loader.rb', line 50

def load
  return if @type == "metadata"
  require "droonga/plugin/#{@type}/#{@name}"
end