lib/plugin_manager.rb in plugin_manager-1.3 vs lib/plugin_manager.rb in plugin_manager-1.4

- old
+ new

@@ -126,11 +126,11 @@ raise "can't find plugin named #{n}" end Dependency.new(self, n, ">0") end end - remaining_to_load = expand_dependencies(target_dependencies) + remaining_to_load = remove_already_loaded_dependencies(expand_dependencies(target_dependencies)) while remaining_to_load.length > 0 previous_length = remaining_to_load.length if plugin = next_to_load(remaining_to_load) load_plugin(plugin) remaining_to_load = remaining_to_load.reject {|dep| dep.required_name == plugin.name } @@ -174,16 +174,22 @@ previous_length = dependency_array.length new_dependency_array = dependency_array.map do |dep| if pl = latest_version_by_name(dep.required_name) [dep, pl.dependencies] else - dep + raise "couldn't find a plugin called #{dep.required_name}" end - end.flatten.uniq + end.flatten.compact.uniq if new_dependency_array.length > previous_length expand_dependencies(new_dependency_array) else new_dependency_array + end + end + + def remove_already_loaded_dependencies(dependency_array) + dependency_array.reject do |dep| + loaded_plugins.map(&:name).include?(dep.required_name) end end def next_to_load(dependency_array) hash = Hash.new {|h,k| h[k] = []}