Module: Slideshow::PluginHelper
- Included in:
- Plugins
- Defined in:
- lib/slideshow/plugin_helpers.rb
Instance Method Summary collapse
Instance Method Details
#find_plugin_patterns ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/slideshow/plugin_helpers.rb', line 7 def find_plugin_patterns patterns = [] ### # todo/fix: only include rb files listed in plugin manifests! # - for now load all ruby files in plugins folder patterns << "#{config.config_dir}/plugins/**/*.rb" ###### # also allow "ad-hoc" plugins e.g. no manifest required (not installed) # just ruby scripts in lib in config folder or working folder patterns << "#{config.config_dir}/lib/**/*.rb" ######### # todo/fix: only include rb files listed in plugin manifest (see above!) patterns << 'plugins/**/*.rb' patterns << 'lib/**/*.rb' unless Slideshow.root == File.( '.' ) # don't include lib if we are in repo (don't include slideshow/lib) patterns end |
#find_plugins ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/slideshow/plugin_helpers.rb', line 31 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_plugins ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/slideshow/plugin_helpers.rb', line 44 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 ## NB: use full_path - since Ruby 1.9.2 - ./ no longer included in load path for security plugin_fullpath = File.( plugin ) # nb: will use Dir.pwd (e.g. ./) as second arg puts "Loading plugins in '#{plugin}' (#{plugin_fullpath})..." require( plugin_fullpath ) rescue Exception => e puts "** error: failed loading plugins in '#{plugin}': #{e}" end end end end |