-
Notifications
You must be signed in to change notification settings - Fork 30
/
init.rb
64 lines (58 loc) · 2.69 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true
# Redmine Issue Badge Plugin
#
# This is a plugin for Redmine to show how many issues are assigned to me via badge.
# Created by Akiko Takano.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine'
require_dependency File.expand_path('../lib/issue_badge/application_hooks', __FILE__)
require_dependency File.expand_path('../lib/issue_badge/my_account_hooks', __FILE__)
require_dependency File.expand_path('../lib/issue_badge/my_controller_patch', __FILE__)
# NOTE: Keep error message for a while to support Redmine3.x users.
def issue_badge_version_message(original_message = nil)
<<-"USAGE"
==========================
#{original_message}
If you use Redmine3.x, please use Redmine Issue Badge version 0.0.7 or clone via
'support-Redmine3' branch.
You can download older version from here: https://github.com/akiko-pusu/redmine_issue_badge/releases
==========================
USAGE
end
Redmine::Plugin.register :redmine_issue_badge do
begin
name 'Redmine Issue Badge plugin'
author 'Akiko Takano'
description 'Plugin to show the number of assigned issues with badge on top menu.'
version '1.0.0'
url 'https://github.com/akiko-pusu/redmine_issue_badge'
author_url 'http://twitter.com/akiko_pusu'
requires_redmine version_or_higher: '5.0'
settings partial: 'settings/redmine_issue_badge',
default: {
'activate_for_all_users' => 'false',
'enabled_polling' => false,
'number_to_display' => 5
}
zeitwerk_enabled = Rails.version > '6.0' && Rails.autoloaders.zeitwerk_enabled?
Rails.configuration.__send__(zeitwerk_enabled ? :after_initialize : :to_prepare) do
require_dependency 'my_controller'
MyController.prepend IssueBadge::MyControllerPatch unless MyController.included_modules.include?(IssueBadge::MyControllerPatch)
end
rescue ::Redmine::PluginRequirementError => e
raise ::Redmine::PluginRequirementError.new(issue_badge_version_message(e.message)) # rubocop:disable Style/RaiseArgs
end
end