lib/chronicle/etl/registry/plugin_registry.rb in chronicle-etl-0.4.2 vs lib/chronicle/etl/registry/plugin_registry.rb in chronicle-etl-0.4.3

- old
+ new

@@ -34,12 +34,15 @@ # Activate a plugin with given name by `require`ing it def self.activate(name) # By default, activates the latest available version of a gem # so don't have to run Kernel#gem separately require "chronicle/#{name}" - rescue LoadError - raise Chronicle::ETL::PluginLoadError.new(name), "Plugin #{name} couldn't be loaded" if exists?(name) + rescue Gem::ConflictError => e + # TODO: figure out if there's more we can do here + raise Chronicle::ETL::PluginConflictError.new(name), "Plugin '#{name}' couldn't be loaded. #{e.message}" + rescue LoadError => e + raise Chronicle::ETL::PluginLoadError.new(name), "Plugin '#{name}' couldn't be loaded" if exists?(name) raise Chronicle::ETL::PluginNotAvailableError.new(name), "Plugin #{name} doesn't exist" end # Install a plugin to local gems @@ -47,12 +50,14 @@ gem_name = "chronicle-#{name}" raise(Chronicle::ETL::PluginNotAvailableError.new(gem_name), "Plugin #{name} doesn't exist") unless exists?(gem_name) Gem::DefaultUserInteraction.ui = Gem::SilentUI.new Gem.install(gem_name) + + activate(name) rescue Gem::UnsatisfiableDependencyError # TODO: we need to catch a lot more than this here - raise Chronicle::ETL::PluginNotAvailableError.new(name), "Plugin #{name} doesn't exist" + raise Chronicle::ETL::PluginNotAvailableError.new(name), "Plugin #{name} could not be installed." end # Uninstall a plugin def self.uninstall(name) gem_name = "chronicle-#{name}"