This post originated from an RSS feed registered with Ruby Buzz
by Florian Frank.
Original Post: Rubygems plugin for Typo
Feed Title: The Rubylution
Feed URL: http://rubylution.ping.de/xml/rss/feed.xml
Feed Description: The Rubylution is a weblog (mainly) about Ruby Programming.
I just made a new sidebar plugin for Typo (http://typo.leetsoft.com), which powers my blog. You can see the result on the right sidebar.
It's so nice to be able to have multiple instances of the same plugin. The only problem with my plugin is, that rubygems
does a stupid thing: It includes a 'rubygems/open-uri.rb' file that includes a copy of the 'open-uri.rb' file, that comes with Ruby's standard library. The Gems RemoteInstaller requires it, and I had some strange cases of infinite recursion, because the Standard lib 'open-uri' is also required by Typo.
This is probably done to be compatible to earlier versions of Ruby, which didn't include 'open-uri.rb'. I patched Rubygems to make this a bit more sane:
--- remote_installer.rb.bak 2005-11-12 18:17:16.330519355 +0100
+++ remote_installer.rb 2005-11-12 18:17:41.877160601 +0100
@@ -114,7 +114,11 @@
# Read the data from the (source based) URI, but if it is a
# file:// URI, read from the filesystem instead.
def open_uri_or_path(uri, &block)
- require 'rubygems/open-uri'
+ begin
+ require 'open-uri'
+ rescue LoadError
+ require 'rubygems/open-uri'
+ end
if is_file_uri(uri)
open(get_file_uri_path(uri), &block)
else
I hope this patch will be applied to Rubygems.
Update: It turns out, that the copying of the original 'open-uri.rb' was done to work around an early bug in the early 1.8.0. versions of ruby. The fix seems to be, just to require 'open-uri', because it had been fixed since this version.