From 98bda86f3386cf42bf146ea4cc4cce44a59865d6 Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Sun, 10 Nov 2024 16:51:08 +0100 Subject: [PATCH] plugin required added --- lib/redmine_plugin_kit/plugin_base.rb | 19 +++++++++++++++++++ lib/redmine_plugin_kit/version.rb | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/redmine_plugin_kit/plugin_base.rb b/lib/redmine_plugin_kit/plugin_base.rb index 2f6b5d7..09c2e5c 100644 --- a/lib/redmine_plugin_kit/plugin_base.rb +++ b/lib/redmine_plugin_kit/plugin_base.rb @@ -11,6 +11,7 @@ def setup!(existing_loader = nil) init_loader existing_loader raise "no loader for #{plugin_id}" if loader.nil? + setup_required_plugins setup end @@ -37,6 +38,24 @@ def setting?(value) private + # rubocop: disable Style/RaiseArgs + def setup_required_plugins + return unless defined? self::REQUIRED_ALPHANODES_PLUGINS + raise 'VERSION missing for REQUIRED_ALPHANODES_PLUGINS' unless defined? self::VERSION + + self::REQUIRED_ALPHANODES_PLUGINS.each do |required_plugin| + plugin = Redmine::Plugin.find required_plugin + unless self::VERSION.include? plugin.version + raise Redmine::PluginRequirementError.new "#{plugin_id} plugin requires #{required_plugin} plugin version #{self::VERSION}" + end + rescue Redmine::PluginNotFound + raise Redmine::PluginRequirementError.new "#{plugin_id} plugin requires the #{required_plugin} plugin." \ + "Please install #{required_plugin} plugin (https://alphanodes.com/#{required_plugin.tr '-', + '_'})" + end + end + # rubocop: enable Style/RaiseArgs + def init_loader(existing_loader) @loader = existing_loader end diff --git a/lib/redmine_plugin_kit/version.rb b/lib/redmine_plugin_kit/version.rb index 1bb3a01..238cee3 100644 --- a/lib/redmine_plugin_kit/version.rb +++ b/lib/redmine_plugin_kit/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RedminePluginKit - VERSION = '1.0.5' + VERSION = '1.0.6' end