Module: Slideshow::PluginHelper

Included in:
PluginLoader, Plugins
Defined in:
lib/slideshow/plugin_helpers.rb

Instance Method Summary collapse

Instance Method Details

#find_plugin_patternsObject



5
6
7
8
9
10
# File 'lib/slideshow/plugin_helpers.rb', line 5

def find_plugin_patterns
  patterns = []
  patterns << "#{config.config_dir}/lib/**/*.rb"
  patterns << 'lib/**/*.rb' unless Slideshow.root == File.expand_path( '.' )  # don't include lib if we are in repo (don't include slideshow/lib)    
  patterns
end

#find_pluginsObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/slideshow/plugin_helpers.rb', line 12

def find_plugins
  patterns = find_plugin_patterns

  plugins=[]
  patterns.each do |pattern|
    pattern.gsub!( '\\', '/')  # normalize path; make sure all path use / only
    Dir.glob( pattern ) do |plugin|
      plugins << plugin
    end
  end
  plugins
end

#load_pluginsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/slideshow/plugin_helpers.rb', line 25

def load_plugins
  patterns = find_plugin_patterns

  patterns.each do |pattern|
    pattern.gsub!( '\\', '/')  # normalize path; make sure all path use / only
    Dir.glob( pattern ) do |plugin|
      begin
        puts "Loading plugins in '#{plugin}'..."
        require( plugin )
      rescue Exception => e
        puts "** error: failed loading plugins in '#{plugin}': #{e}"
      end
    end
  end
end