Austin Ziegler wrote:
I'm writing some code that depends on MIME::Types, and works
better with (but does not depend on) BlueCloth.
What sort of application is it? (I'm curious, of course, as I wrote
MIME::Types 
Well, if you *must* know, it takes either a string of XHTML or plain-text and produces a MIME multipart/alternative message body. The code looks at the given string and automagically creates the alternative rendering (given, XHTML, it also creates a plain-text version, and vice versa. Works best when handed a BlueCloth string, but the plain-to-peanuts conversion is configurable).
If the resulting (or given) XHTML contains local references to images, they are encoded and added to the message body as multipart/related; the img src value is replace with a cid: ref to the encoded image segment.
MIME::Types is used to figure out the MIME type of the image.
With Ruwiki, we depended on Algorithm::Diff -- and we will be
depending on Diff::LCS -- and I will be packaging Diff::LCS with
Ruwiki. This is because Ruwiki is intended to be standalone, except
for the Ruby core libraries. Ruwiki ensures that its versions will
be loaded in preference to system versions by modifying $LOAD_PATH
such that the Ruwiki library directory is first.
I've got a similar deal with Blogtari (also stand-alone, with no assumptions about user permissions other than their on httpdocs or public_html directory), which includes RedCloth and BlueCloth, but it will try to first load them from the standard path.
If and when I make it "installable" rather than an "unpack and run"
program, I will do further work with the install.rb such that I do a
"require 'diff/lcs'" (and any other dependencies); if it is not
found, then I will install Diff::LCS. If it is found, then I will
check to make sure that it is at least version 1.1. If not, then I
will prompt the user for replacement. Now, the real problem is that
Ruwiki -- as of right now -- only includes those parts of Diff::LCS
which are necessary to run Ruwiki. Thus, if I take that route, I
will probably offer multiple packages.
Blogtari has its own installation routine. Everything is packed up using a hacked version of Tar2Rubyscript (quite slick); there's code in there to prompt the user for configuration details, as well as try to managed upgrades without stomping existing user config data or templates. But nothing to verify available dependencies.
An alternative -- and perhaps better way for the .tar.gz concept --
is to provide the required and optional packages as .tar.gz packages
within one of your distribution packages. This means that
OS-specific packagers don't have to strip out the code by hand, and
you don't have to worry about those tests.
bin/
dep/required/mime-types-1.13.tar.gz
dep/optional/bluecloth-0.3.2.tar.gz
...
That's a really good idea. I think my biggest gripe with packages with multiple dependencies is that they send you off on a series of hunt and fetch operations. (This is *especially* annoying if you've loaded your laptop with assorted libs to examine for a presentation you plan on writing on the plane ride to a conference. Or so I hear.)
So simply bundling the required libs in such a way that the user at least has them to install is a good compromise. And I like the directory tree.
That said, if you have a standalone situation as we have with
Ruwiki, feel free to include MIME::Types or any of my other
packages. I have RubyForge projects for MIME::Types, Text::Format,
and Transaction::Simple, now -- I just haven't announced them.
Sweet. Thanks.
James
···
On Fri, 30 Jul 2004 06:18:18 +0900, James Britt > <jamesunderbarb@neurogami.com> wrote:
-austin