Sha256: edd022c1190fa05c974625952bd7f5de990321e1a66d903775e08839110b4e41

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

module Slideshow

module PluginHelper

  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

  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

  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  # method load_plugins


end # module PluginHelper
end # module Slideshow

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
slideshow-2.0.0 lib/slideshow/plugin_helpers.rb
slideshow-1.2.5 lib/slideshow/plugin_helpers.rb
slideshow-1.2.4 lib/slideshow/plugin_helpers.rb
slideshow-1.2.3 lib/slideshow/plugin_helpers.rb
slideshow-1.2.2 lib/slideshow/plugin_helpers.rb
slideshow-1.2.1 lib/slideshow/plugin_helpers.rb
slideshow-1.2.0 lib/slideshow/plugin_helpers.rb
slideshow-1.2.0.beta5 lib/slideshow/plugin_helpers.rb
slideshow-1.2.0.beta4 lib/slideshow/plugin_helpers.rb
slideshow-1.2.0.beta3 lib/slideshow/plugin_helpers.rb
slideshow-1.2.0.beta2 lib/slideshow/plugin_helpers.rb