[rubygems/rubygems] Restore gem_dir as an instance variable accessor

I suspect someone could be setting this instance variable, and the
previous changes made that no longer effective.

Also I implemented a previous TOOD in `full_gem_path` the other way
around:

> # TODO: This is a heavily used method by gems, so we'll need
> # to aleast just alias it to #gem_dir rather than remove it.

I made `gem_dir` an alias of `full_gem_path` rather than the opposite.

This alternative change keeps both methods symmetric without deprecating
either of them for now.

https://github.com/rubygems/rubygems/commit/28983973a3
This commit is contained in:
David Rodríguez 2024-09-18 19:00:18 +02:00 committed by Hiroshi SHIBATA
parent 5f47f0f759
commit 5228d349d9
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -136,13 +136,13 @@ class Gem::BasicSpecification
## ##
# The full path to the gem (install path + full name). # The full path to the gem (install path + full name).
#
# TODO: This is duplicated with #gem_dir. Eventually either of them should be deprecated.
def full_gem_path def full_gem_path
@full_gem_path ||= find_full_gem_path @full_gem_path ||= find_full_gem_path
end end
alias_method :gem_dir, :full_gem_path
## ##
# Returns the full name (name-version) of this Gem. Platform information # Returns the full name (name-version) of this Gem. Platform information
# is included (name-version-platform) if it is specified and not the # is included (name-version-platform) if it is specified and not the
@ -212,6 +212,16 @@ class Gem::BasicSpecification
end end
end end
##
# Returns the full path to this spec's gem directory.
# eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0
#
# TODO: This is duplicated with #full_gem_path. Eventually either of them should be deprecated.
def gem_dir
@gem_dir ||= find_full_gem_path
end
## ##
# Returns the full path to the gems directory containing this spec's # Returns the full path to the gems directory containing this spec's
# gem directory. eg: /usr/local/lib/ruby/1.8/gems # gem directory. eg: /usr/local/lib/ruby/1.8/gems