redmine_plugin_kit 1.0.8 → 1.0.10

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: 742a6b7ef926f76e6c7615961748e673590423a410041567a15743692337e753
4
+ data.tar.gz: 2a63b5273c96b44f8c42f7f473a462acf2352979137331e61b3baca6fd835e1f
5
5
  SHA512:
6
- metadata.gz: 516210aeab2395b927086b354b913eeca88e7aed1de3f7674aad6d6efb0bcd602897eefd28f108c00d13519f9cb27df51167638937516ec3d9793577ad52d3c9
7
- data.tar.gz: 4579bbdaed1f2dec0bce766f18bd3344398f303c5417b8944312945a63894a750cad7f4fce3d41bb2ebd5082e06ccc5f3aa4f6ae26ff8e56d042b27cce205f0d
6
+ metadata.gz: 3b339aad3aa4192aecc5b385678b656a93e1b3e820f0d7f20500f89c8bd35f81be1c2dd49c66e860721b75d4b856bd4058a7eced562941ee802df0738c48f967
7
+ data.tar.gz: 4d11d3f39bcc013d6addd4cbc03ada64a13f51b0be1e5ca446f693f4a6e88e0c7431a67415078ee88df07d49336395a7986e04778ef513061f9da5e96355357c
@@ -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.10'
5
5
  end
@@ -26,6 +26,17 @@ module RedminePluginKit
26
26
  !true?(value)
27
27
  end
28
28
 
29
+ # Returns plugin settings with indifferent access and the given setting applied.
30
+ # Redmine stores plugin settings from the settings form this way, too. Without it,
31
+ # a string key from the command line would be added next to an existing symbol key,
32
+ # and plugins reading the symbol key would never see the new value.
33
+ def plugin_settings_with(settings, setting, value)
34
+ settings = {} unless settings.is_a? Hash
35
+ settings = settings.with_indifferent_access
36
+ settings[setting] = value
37
+ settings
38
+ end
39
+
29
40
  def textarea_cols(text, min: 8, max: 20)
30
41
  [[min, text.to_s.length / 50].max, max].min # rubocop: disable Style/ComparableClamp
31
42
  end
@@ -46,9 +46,7 @@ namespace :redmine_plugin_kit do
46
46
  Setting[setting.to_sym] = value
47
47
  else
48
48
  plugin_name = :"plugin_#{name}"
49
- plugin_settings = Setting[plugin_name]
50
- plugin_settings[setting] = value
51
- Setting[plugin_name] = plugin_settings
49
+ Setting[plugin_name] = RedminePluginKit.plugin_settings_with Setting[plugin_name], setting, value
52
50
  end
53
51
  end
54
52
 
@@ -76,7 +74,7 @@ namespace :redmine_plugin_kit do
76
74
  else
77
75
  plugin_name = :"plugin_#{name}"
78
76
  plugin_settings = Setting[plugin_name]
79
- puts plugin_settings[setting]
77
+ puts plugin_settings.with_indifferent_access[setting] if plugin_settings.is_a? Hash
80
78
  end
81
79
  end
82
80
 
Binary file
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.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlphaNodes
@@ -55,6 +55,7 @@ files:
55
55
  - lib/redmine_plugin_kit/plugin_base.rb
56
56
  - lib/redmine_plugin_kit/version.rb
57
57
  - lib/tasks/redmine_plugin_kit.rake
58
+ - redmine_plugin_kit-1.0.9.gem
58
59
  homepage: https://github.com/alphanodes/redmine_plugin_kit
59
60
  licenses:
60
61
  - GPL-2.0