Skip to content

Commit

Permalink
plugin required added
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Nov 10, 2024
1 parent ec6606f commit 98bda86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/redmine_plugin_kit/plugin_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_plugin_kit/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RedminePluginKit
VERSION = '1.0.5'
VERSION = '1.0.6'
end

0 comments on commit 98bda86

Please sign in to comment.