lib/chronicle/etl/registry/plugin_registry.rb in chronicle-etl-0.5.3 vs lib/chronicle/etl/registry/plugin_registry.rb in chronicle-etl-0.5.4
- old
+ new
@@ -9,10 +9,22 @@
# Responsible for managing plugins available to chronicle-etl
#
# @todo Better validation for whether a gem is actually a plugin
# @todo Add ways to load a plugin that don't require a gem on rubygems.org
module PluginRegistry
+ class << self
+ # Start of a system for having non-gem plugins. Right now, we just
+ # make registry aware of existenc of name of non-gem plugin
+ def register_standalone(name)
+ standalones << name
+ end
+
+ def standalones
+ @standalones ||= []
+ end
+ end
+
# Does this plugin exist?
def self.exists?(name)
# TODO: implement this. Could query rubygems.org or use a hardcoded
# list somewhere
true
@@ -31,11 +43,10 @@
.values
end
# Check whether a given plugin is installed
def self.installed?(name)
- gem_name = "chronicle-#{name}"
- all_installed.map(&:name).include?(gem_name)
+ (standalones + all_installed.map { |gem| gem.name.gsub("chronicle-", "") }).include?(name)
end
# Activate a plugin with given name by `require`ing it
def self.activate(name)
# By default, activates the latest available version of a gem