redmine_plugin_kit 1.0.8 → 1.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b950fef55b36b8c083f86f9763d9528a259c42b85da7f238ac94ba9dd85ca40
4
- data.tar.gz: b425a3447f2b07ded747e329d6b482010e8404a36d9842f3415aa06c5232b959
3
+ metadata.gz: 94857a34d940b2fccba2f613e3299cef59acc88c20c3279671831fd923c3e28e
4
+ data.tar.gz: 4d6e9c22ea18b5050b9084fe60b577a4cb3da032801a13a0b16f6ec99664a443
5
5
  SHA512:
6
- metadata.gz: 516210aeab2395b927086b354b913eeca88e7aed1de3f7674aad6d6efb0bcd602897eefd28f108c00d13519f9cb27df51167638937516ec3d9793577ad52d3c9
7
- data.tar.gz: 4579bbdaed1f2dec0bce766f18bd3344398f303c5417b8944312945a63894a750cad7f4fce3d41bb2ebd5082e06ccc5f3aa4f6ae26ff8e56d042b27cce205f0d
6
+ metadata.gz: 90fe0d769fa01295f8dea757cff3aa5f9dc48005c8ee4ea356b6cdece1da7e0330f11020359cee3f9cb53c587eaa95281c7b7d1493d4a95be8cad1e7dbe26ad9
7
+ data.tar.gz: f3d7a85ab307ffe4425229878f41581e03a04a833e34f626e8336ae52005e6f2a04be166517d6fcdb6b32489ceda1d08ba2d58ebef77f3265547c71a9ebf605f
@@ -89,11 +89,34 @@ module RedminePluginKit
89
89
 
90
90
  files.reverse! if reverse
91
91
  files.each do |f|
92
- Rails.autoloaders.main.ignore << f if Rails.version > '6.0' && ignore_autoload
92
+ if Rails.version > '6.0' && ignore_autoload
93
+ Rails.autoloaders.main.ignore << f
94
+ # Such a file registers itself in a registry that lives on a module
95
+ # Zeitwerk rebuilds on every reload (Redmine::FieldFormat). The
96
+ # registration is lost with the old module, and require would be a
97
+ # no-op the second time round - the custom field then falls back to a
98
+ # plain text field showing the raw id. Reloading the file restores it.
99
+ #
100
+ # NOTE: the require below stays as it is, so booting behaves exactly as
101
+ # before and does not depend on when to_prepare runs. Loading the file
102
+ # again in the first prepare run is harmless: these files only define a
103
+ # class and register it under a fixed name.
104
+ reload_on_prepare f
105
+ end
106
+
93
107
  require f
94
108
  end
95
109
  end
96
110
 
111
+ # Load the file again after every code reload.
112
+ #
113
+ # The block keeps the order of the surrounding loop, which matters because
114
+ # formats may inherit from each other (CompanyFormat < ContactFormat) - a
115
+ # subclass loaded before its parent raises NameError.
116
+ def reload_on_prepare(file)
117
+ ActiveSupport::Reloader.to_prepare { load file }
118
+ end
119
+
97
120
  def incompatible?(plugins = [])
98
121
  plugins.each do |plugin|
99
122
  raise "\n\033[31m#{plugin_id} plugin cannot be used with #{plugin} plugin.\033[0m" if Redmine::Plugin.installed? plugin
@@ -38,6 +38,19 @@ module RedminePluginKit
38
38
 
39
39
  private
40
40
 
41
+ # Enforce a plugin's REQUIRED_ALPHANODES_PLUGINS (an array of plugin ids it
42
+ # hard-depends on). Called from setup! which runs via the
43
+ # after_plugins_loaded hook, i.e. AFTER every plugin is registered - so the
44
+ # alphabetical plugin load order is irrelevant here.
45
+ #
46
+ # This is why AlphaNodes plugins declare dependencies on other redmine_*
47
+ # plugins via REQUIRED_ALPHANODES_PLUGINS instead of requires_redmine_plugin:
48
+ # requires_redmine_plugin runs while init.rb is loaded (during alphabetical
49
+ # registration) and therefore only works for dependencies that load earlier,
50
+ # such as additionals / additional_tags. A dependency that loads later (e.g.
51
+ # redmine_automation depending on redmine_reporting) would raise
52
+ # PluginNotFound even though it is installed. To see a plugin's hard
53
+ # AlphaNodes dependencies, look at its REQUIRED_ALPHANODES_PLUGINS constant.
41
54
  # rubocop: disable Style/RaiseArgs
42
55
  def setup_required_plugins
43
56
  return unless defined? self::REQUIRED_ALPHANODES_PLUGINS
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RedminePluginKit
4
- VERSION = '1.0.8'
4
+ VERSION = '1.0.9'
5
5
  end
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.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlphaNodes