[Rubygems-developers] Name collisions (Help me avoid hate mail
while using descriptive names)
Eric Hodel
drbrain at segment7.net
Sat Jun 4 21:53:20 EDT 2005
On 04 Jun 2005, at 17:30, Eric Hodel wrote:
> On 04 Jun 2005, at 17:10, Eric Hodel wrote:
>
>> Last night I uploaded rails_analyzer_tools (and rails-analyzer-
>> tools, which gave inconsistent names to the other packages...) and
>> now "rails-analyzer-tools" gets installed instead of "rails" when
>> I "gem install rails":
>>
>> I'd like to keep the name 'rails_analyzer_tools', but at the same
>> time I don't want to get any hate-mail from Rails fanboys because
>> they now have to specify a version to get rails.
>>
>> I thought something had been done about this exact vs relative
>> matching thing, but I'm too lazy to crawl through the archives in
>> search of it.
>
> Ok, looking at the sources, I see what the problem is that exact
> name search is never done. I will try to whip up some test cases
> and a patch.
I now have a proposed patch, the heart of which is this:
Index: lib/rubygems/remote_installer.rb
===================================================================
RCS file: /var/cvs/rubygems/rubygems/lib/rubygems/remote_installer.rb,v
retrieving revision 1.80
diff -u -r1.80 remote_installer.rb
--- lib/rubygems/remote_installer.rb 24 Mar 2005 05:37:36
-0000 1.80
+++ lib/rubygems/remote_installer.rb 5 Jun 2005 01:30:11 -0000
@@ -425,36 +425,44 @@
# Find a gem to be installed by interacting with the user.
def find_gem_to_install(gem_name, version_requirement, caches)
- max_version = Version.new("0.0.0")
specs_n_sources = []
+
caches.each do |source, cache|
cache.each do |name, spec|
- if (/^#{gem_name}-/i === name &&
- version_requirement.satisfied_by?(spec.version))
+ if /^#{gem_name}$/i === spec.name &&
+ version_requirement.satisfied_by?(spec.version) then
specs_n_sources << [spec, source]
end
end
end
(The full patch does much more cleanup, because the method was
completely unreadable.)
So...
$ gem install foo
Will install "foo-1.2.3"
In the presence of:
foo-1.2.3
foo-tools-2.0.0
foo-2-2.0.0 # if the regex is /#{gem_name}-\d/ this gets installed
instead of foo.
But I have a funny feeling about this:
- if specs_n_sources.reject { |item|
- item[0].platform.nil? || item[0].platform==Platform::RUBY
- }.size == 0
- # only non-binary gems...return latest
- return specs_n_sources.first
+
+ non_binary_gems = specs_n_sources.reject { |item|
+ item[0].platform.nil? || item[0].platform==Platform::RUBY
+ }
+
+ # only non-binary gems...return latest
+ return specs_n_sources.first if non_binary_gems.empty?
+
Why are non-binary gems special?
--
Eric Hodel - drbrain at segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
More information about the Rubygems-developers
mailing list