summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-12-05 09:23:28 +0100
committergit <svn-admin@ruby-lang.org>2021-12-06 18:43:29 +0900
commitd044ffd77fb3a486bbaca350980beee3f222bdb1 (patch)
tree981fe291a44b1bbbde21908b6646c996bd482414 /lib/rubygems
parente41c195cc52b2ce1ba00126917be606d52d75a30 (diff)
[rubygems/rubygems] Allow using `Gem::Version` without loading the rest of rubygems
https://github.com/rubygems/rubygems/commit/1b862537a5
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/version.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 20bbff4fdd..37fd71edc0 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -149,6 +149,15 @@
# For the last example, single-digit versions are automatically extended with
# a zero to give a sensible result.
+# Our code style opens classes directly without opening the intermediate
+# modules. This works because tha main entrypoint `rubygems.rb`, which defines
+# the root `Gem` module, is usually required first. But in this case we want to
+# allow using `Gem::Version` without loading the rest of rubygems, so we
+# explicit define the `Gem` placeholder module first.
+module Gem; end
+
+require_relative "deprecate"
+
class Gem::Version
autoload :Requirement, File.expand_path('requirement', __dir__)