Skip to content

Commit

Permalink
* lib/rubygems/installer.rb: don't warn about not being able to
Browse files Browse the repository at this point in the history
   install a library stub if a library stub is already installed.
   Still warn if it's not a library stub that's there already.


git-svn-id: http://rubygems.rubyforge.org/svn/trunk@285 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information
gsinclair committed Jun 8, 2004
1 parent 972535d commit e9141c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions rubygems/ChangeLog
@@ -1,3 +1,8 @@
2004-06-08 Gavin Sinclair <gsinclair@soyabean.com.au>
* lib/rubygems/installer.rb: don't warn about not being able to
install a library stub if a library stub is already installed.
Still warn if it's not a library stub that's there already.

2004-06-08 Gavin Sinclair <gsinclair@soyabean.com.au>
* bin/gem: renamed --upgrade-dist to --upgrade--all and fixed bug.
* lib/rubygems/installer.rb: fixed bug with Ruby version assertion.
Expand Down
21 changes: 17 additions & 4 deletions rubygems/lib/rubygems/installer.rb
Expand Up @@ -159,10 +159,12 @@ def generate_library_stubs(spec)
sitelibdir = Config::CONFIG['sitelibdir']
if FileTest.writable?(sitelibdir)
target_file = File.join(sitelibdir, "#{spec.autorequire}.rb")
if FileTest.exist?(target_file)
STDERR.puts "(WARN) Library file '#{target_file}'"
STDERR.puts " already exists; not overwriting. If you want to force a"
STDERR.puts " library stub, delete the file and reinstall."
if FileTest.exist?(target_file)
unless library_stub?(target_file)
STDERR.puts "(WARN) Library file '#{target_file}'"
STDERR.puts " already exists; not overwriting. If you want to force a"
STDERR.puts " library stub, delete the file and reinstall."
end
else
# Create #{autorequire}.rb in #{target_dir}.
unless File.exist? File.dirname(target_file)
Expand Down Expand Up @@ -199,6 +201,17 @@ def library_stub_text(name, file_name)
TEXT
text
end

##
# Returns true iff the given filename contains a library stub. (Best guess!)
#
def library_stub?(filename)
lines = File.read(filename)
lines.grep(/^# This file was generated by RubyGems/) and
lines.grep(/is installed as part of a gem, and/) and
lines.grep(/^#/).size == 7 and
lines.size == 11
end

def build_extensions(directory, spec)
return unless spec.extensions.size > 0
Expand Down

0 comments on commit e9141c6

Please sign in to comment.