Sha256: e317620737d9cea0f06ab04dc7ab2be16607291120c709ea6c955582a78a15df

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

# = Plugin Manger
#
# Find plugins easily.
#
# NOTE: This is likely to be replaced with
# a more generic means of finding libraries.
#
module PluginManager
  extend self

  # Find plugins, searching through standard $LOAD_PATH,
  # Roll Libraries and RubyGems.
  #
  # +match+ is a file glob for finding plugins.
  #
  #   PluginManager.find('syckles/*')
  #
  def find(match)
    plugins = []
    # Standard $LOAD_PATH
    $LOAD_PATH.uniq.each do |path|
      list = Dir.glob(File.join(path, match))
      #dirs = dirs.select{ |d| File.directory?(d) }
      list = list.map{ |d| d.chomp('/') }
      plugins.concat(list)
    end
    # ROLL (load latest versions only)
    if defined?(::Roll)
      ::Roll::Library.ledger.each do |name, lib|
        lib = lib.sort.first if Array===lib
        lib.load_path.each do |path|
          find = File.join(lib.location, path, match)
          list = Dir.glob(find)
          list = list.map{ |d| d.chomp('/') }
          plugins.concat(list)
        end
      end
    end
    # RubyGems (load latest versions only)
    if defined?(::Gem)
      Gem.latest_load_paths do |path|
        list = Dir.glob(File.join(path, match))
        list = list.map{ |d| d.chomp('/') }
        plugins.concat(list)
      end
    end
    plugins
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.8.2 lib/more/facets/plugin_manager.rb
facets-2.8.1 lib/more/facets/plugin_manager.rb
facets-2.8.0 lib/more/facets/plugin_manager.rb