Class: Droonga::PluginLoader

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePluginLoader

Returns a new instance of PluginLoader.



33
34
# File 'lib/droonga/plugin_loader.rb', line 33

def initialize
end

Class Method Details

.load_allObject



27
28
29
30
# File 'lib/droonga/plugin_loader.rb', line 27

def load_all
  loader = new
  loader.load_all
end

Instance Method Details

#load(name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/droonga/plugin_loader.rb', line 36

def load(name)
  logger.debug("loading...: <#{name}>")
  path = "droonga/plugins/#{name}"
  begin
    require path
  rescue StandardError, SyntaxError => error
    logger.exception("failed to load: <#{path}>", error)
    raise
  end
end

#load_allObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/droonga/plugin_loader.rb', line 47

def load_all
  $LOAD_PATH.each do |load_path|
    search_pattern = "#{load_path}/droonga/plugins/*.rb"
    logger.debug("searching...: <#{search_pattern}>")
    Pathname.glob(search_pattern) do |plugin_path|
      name = Pathname(plugin_path).basename(".rb").to_s
      load(name)
    end
  end
end