From: "Eregon (Benoit Daloze)" Date: 2021-12-06T12:36:34+00:00 Subject: [ruby-core:106506] [Ruby master Feature#18376] Version comparison API Issue #18376 has been updated by Eregon (Benoit Daloze). deivid (David Rodr��guez) wrote in #note-22: > Something like https://github.com/rubygems/rubygems/pull/5136 would already address the "I don't want to load all of rubygems just to compare some versions" concern. Unfortunately this does not work if RubyGems is loaded lazily via `autoload :Gem, 'rubygems'` (it will load all of RubyGems on `require 'rubygems/version'`). And also this seems quite confusing if the `Gem` constant is defined but all the constants/classes under `Gem` are not there and would be `NameError` when accessing them, unless `require 'rubygems'` is done before those accesses: ``` $ ruby --disable-gems -e 'require "rubygems/version"; p Gem::Version; p Gem::Specification' Gem::Version -e:1:in `
': uninitialized constant Gem::Specification (NameError) ``` For this reason, IMHO that PR should be reverted. > But if we extracted rubygems `version.rb` file to a new default gem, that would provide the same functionality through the `::Version` class for users that explicitly `require "version"`, also addressing the "`Gem::Version` is confusing for some version usages not related to gems" concern. Nothing would have to change for us in rubygems, we would need to vendor `version.rb` under the `Gem` namespace like we do for other default gems, which is exactly what we are already doing. That seems a great idea to me. ---------------------------------------- Feature #18376: Version comparison API https://bugs.ruby-lang.org/issues/18376#change-95166 * Author: vo.x (Vit Ondruch) * Status: Open * Priority: Normal ---------------------------------------- Is there a chance to have version comparison API? For example if `Gem::Version` was extracted into `::Version`. This idea was triggered by this PR [1] and [2], where the `Gem::Version` API is used for comparing Ruby versions. While RubyGems might be available everywhere, it does not look correct to introduce dependencies on RubyGems into libraries which could run without them just fine. [1]: https://github.com/mperham/connection_pool/pull/157 [2]: https://github.com/mperham/connection_pool/issues/158 -- https://bugs.ruby-lang.org/ Unsubscribe: