summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVít Ondruch <vondruch@redhat.com>2023-03-08 18:32:53 +0100
committerVít Ondruch <vondruch@redhat.com>2023-03-08 18:32:53 +0100
commit6709bc25e1459cb60f78902d12afdef88645d810 (patch)
treeb816abbb950757c868a188d7fc660e49afa52500
parentb872a2d28a404289167868cd07cc3d44f75ac802 (diff)
downloaddarkfish-6709bc25e1459cb60f78902d12afdef88645d810.tar.gz
darkfish-6709bc25e1459cb60f78902d12afdef88645d810.tar.xz
darkfish-6709bc25e1459cb60f78902d12afdef88645d810.zip
Fix `RuntimeError` having multiple plugins installedrawhide
Having multiple RubyGems plugins installed (e.g. rubygems-server) in addition to RDoc, the original code was too conservative and causing errors such as: ~~~ $ gem server Error loading RubyGems plugin "/usr/share/gems/plugins/rdoc-generator-fedora-darkfish_plugin.rb": (RuntimeError) Server started at http://0.0.0.0:8808 Server started at http://[::]:8808 ... snip .. ~~~ or ~~~ $ gem list Error loading RubyGems plugin "/usr/share/gems/plugins/rdoc-generator-fedora-darkfish_plugin.rb": (RuntimeError) *** LOCAL GEMS *** abbrev (default: 0.1.1) ... snip ... ~~~ Newly try to load the RDoc hooks and check if we have only one hook afterwards and assume that is the right one. It would be nice to be able to compare if the hook really is the expected `Gem::RDoc.method(:generation_hook)`, but there is no way to do it easily to my knowledge.
-rw-r--r--rubygems_plugin.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/rubygems_plugin.rb b/rubygems_plugin.rb
index 84eeba7..42f50ba 100644
--- a/rubygems_plugin.rb
+++ b/rubygems_plugin.rb
@@ -1,12 +1,12 @@
-# Make sure there are no `done_installing` hooks defined yet, so there is know
-# starting position.
-raise unless Gem.done_installing_hooks.empty?
-
# Initialize the RubyGems RDoc hook.
require "rubygems/rdoc"
-# Double check that there is only one `done_installing` hook loaded.
-raise unless Gem.done_installing_hooks.size == 1
+# Make sure there is only one `done_installing`, so we can assume it it the
+# RDod defined one.
+raise <<~ERR unless Gem.done_installing_hooks.size == 1
+ rdoc-generator-fedora-darkfish expects only one `Gem.done_installing_hooks`
+ at this stage, but #{Gem.done_installing_hooks.size} are defined
+ERR
# Subsequently drop the hook.
Gem.done_installing_hooks.pop