redmine_plugin_kit 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/initializers/deface.rb +7 -3
- data/lib/redmine_plugin_kit/loader.rb +51 -8
- data/lib/redmine_plugin_kit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 437f5cd3183cff072e1ef6e1481cdf2c1455cb9127a8827b06e925cf2fbed17c
|
|
4
|
+
data.tar.gz: aadde8474b6a811142c1d8fe0d9255c9995838418ec40cd308c207c947644142
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d185ff31399258570a19d4d129f66ae17698c3250740986a80fa285cfbfed4887042bfc2ddb6b1ae536544af037feb49a285bffb098493f3e4132bf3351bde7
|
|
7
|
+
data.tar.gz: 48fa844ac993789ac1b13e5a92f9e355d5b411875775880398c01ed1e880abd86a66e67654a233d1dfaf5700e917e10f8686e10b827bb3ae72dec1cd77bd8690
|
data/README.md
CHANGED
|
@@ -19,7 +19,7 @@ If you are a Redmine developer, feel free and offer PRs with your Improvements.
|
|
|
19
19
|
|
|
20
20
|
## Requirements
|
|
21
21
|
|
|
22
|
-
- Redmine `>=
|
|
22
|
+
- Redmine `>= 7.0` (including upcoming)
|
|
23
23
|
- Ruby `>= 3.2` (only maintained ruby versions are supported)
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# The plugin directory of Redmine, as Redmine::PluginLoader uses it: tests may
|
|
4
|
+
# point it elsewhere (REDMINE_PLUGINS_DIRECTORY), so not always plugins/
|
|
5
|
+
plugins_dir = Rails.root.join(Rails.application.config.try(:redmine_plugins_directory) || 'plugins')
|
|
6
|
+
|
|
3
7
|
Rails.application.paths['app/overrides'] ||= []
|
|
4
|
-
|
|
8
|
+
plugins_dir.glob('*/app/overrides').each do |path|
|
|
5
9
|
Rails.application.paths['app/overrides'] << path unless Rails.application.paths['app/overrides'].include? path
|
|
6
10
|
end
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
Deface::DSL::Loader.load
|
|
12
|
+
plugins_dir.glob('*/app/overrides/**/*.deface').each do |path|
|
|
13
|
+
Deface::DSL::Loader.load path.to_s
|
|
10
14
|
end
|
|
@@ -40,6 +40,53 @@ module RedminePluginKit
|
|
|
40
40
|
Gem.loaded_specs[plugin_id].full_gem_path
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
# The files to load again after a code reload, in the order of their
|
|
45
|
+
# registration, each with the number of code reloads it was last loaded
|
|
46
|
+
# at. Kept on the class: the setup of a plugin runs at boot and after
|
|
47
|
+
# every code reload and registers its files each time.
|
|
48
|
+
def reloadable_files
|
|
49
|
+
@reloadable_files ||= {}
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def reload_on_prepare(file)
|
|
53
|
+
watch_code_reloads
|
|
54
|
+
# the require of the caller loads the file for this number of reloads
|
|
55
|
+
reloadable_files[file] ||= code_reloads
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def code_reloads
|
|
61
|
+
@code_reloads ||= 0
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# One callback pair for all files, however often a file is registered
|
|
65
|
+
def watch_code_reloads
|
|
66
|
+
return if @watch_code_reloads
|
|
67
|
+
|
|
68
|
+
@watch_code_reloads = true
|
|
69
|
+
# the callbacks run in the context of the reloader
|
|
70
|
+
loader = self
|
|
71
|
+
ActiveSupport::Reloader.after_class_unload { loader.send :code_reloaded }
|
|
72
|
+
ActiveSupport::Reloader.to_prepare { loader.send :load_unloaded_files }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def code_reloaded
|
|
76
|
+
@code_reloads = code_reloads + 1
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Prepare also runs without a code reload: at boot, and in production and
|
|
80
|
+
# test, where code is never unloaded. The class of a file is still there
|
|
81
|
+
# then, and loading the file again would define its constants twice.
|
|
82
|
+
def load_unloaded_files
|
|
83
|
+
reloadable_files.each do |file, loaded_at|
|
|
84
|
+
next if loaded_at == code_reloads
|
|
85
|
+
|
|
86
|
+
load file
|
|
87
|
+
reloadable_files[file] = code_reloads
|
|
88
|
+
end
|
|
89
|
+
end
|
|
43
90
|
end
|
|
44
91
|
|
|
45
92
|
def initialize(plugin_id:, debug: false)
|
|
@@ -104,9 +151,7 @@ module RedminePluginKit
|
|
|
104
151
|
# plain text field showing the raw id. Reloading the file restores it.
|
|
105
152
|
#
|
|
106
153
|
# NOTE: the require below stays as it is, so booting behaves exactly as
|
|
107
|
-
# before and does not depend on when to_prepare runs.
|
|
108
|
-
# again in the first prepare run is harmless: these files only define a
|
|
109
|
-
# class and register it under a fixed name.
|
|
154
|
+
# before and does not depend on when to_prepare runs.
|
|
110
155
|
reload_on_prepare f
|
|
111
156
|
end
|
|
112
157
|
|
|
@@ -114,14 +159,12 @@ module RedminePluginKit
|
|
|
114
159
|
end
|
|
115
160
|
end
|
|
116
161
|
|
|
117
|
-
# Load the file again after every code reload.
|
|
162
|
+
# Load the file again in the prepare run after every code reload.
|
|
118
163
|
#
|
|
119
|
-
# The
|
|
164
|
+
# The files keep the order of the surrounding loop, which matters because
|
|
120
165
|
# formats may inherit from each other (CompanyFormat < ContactFormat) - a
|
|
121
166
|
# subclass loaded before its parent raises NameError.
|
|
122
|
-
|
|
123
|
-
ActiveSupport::Reloader.to_prepare { load file }
|
|
124
|
-
end
|
|
167
|
+
delegate :reload_on_prepare, to: :class
|
|
125
168
|
|
|
126
169
|
def incompatible?(plugins = [])
|
|
127
170
|
plugins.each do |plugin|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: redmine_plugin_kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- AlphaNodes
|
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
75
75
|
- !ruby/object:Gem::Version
|
|
76
76
|
version: '0'
|
|
77
77
|
requirements: []
|
|
78
|
-
rubygems_version:
|
|
78
|
+
rubygems_version: 4.0.20
|
|
79
79
|
specification_version: 4
|
|
80
80
|
summary: Redmine plugin kit
|
|
81
81
|
test_files: []
|