[Rubygems-developers] Suggestions regarding new CLI

Jim Weirich jim at weirichhouse.org
Sat Jun 26 08:51:07 EDT 2004

Chad Fowler wrote:
> Man, you're moving so fast (and well!) that I can't keep up with my 
> infrequent net access!  I may just resign myself to watch things get 
> better for the next week while we finish our vacation. :)  This stuff is 
> fantastic.

Ok, I think I'm fairly happy with the code base.  At least I'm pulling 
back and letting what's there sink in for a while.  Now would be a good 
time for someone to review what's been done and provide some feedback. 
I'm fairly happy with how the command code has been segregated info 
individual classes and fairly loosely coupled.  In fact, it would not be 
hard at this point to support a "pluggable" command architecture (where 
the gem script "searches" a directory for additional commands and 
automatically adds them), but let's not go there for now.

Oh, found one major incompatibility.  I while back I refactored the 
version and dependency code to support multiple version requirements, so 
we could say:

   require_gem "xzy", "> 1.2", "<= 2.0"

In doing so the structure of Gem::Version::Requirement and 
Gem::Dependency changed.  Old gem files written before the change (e.g. 
copland) would break the code because YAML loaded the object with the 
*old* instance variables.  I added a normalize function to several 
classes to transform out-dated objects into modern objects.   (That was 
a headache!).

Here's a partial list of stuff I've done over the past few days.  They 
will help in reviewing the code base.

* Pulled all command logic out of CommandManager and put them in their
   own classes.  Command is now the base class for all commands.

* Commands now use the template method pattern to implement a command
   (the method name is "execute").  I left "when_invoked" in a command
   to facilitate testing.

* Commands no longer need to return true/false to trigger help.  Help
   processing is implemented in Command so all commands inherit it.

* Added the rubygems-info command back into the code, then changed the
   name to "environment" (as it prints environmental information).  The
   environment command also takes subcommands now.

* Added the "info" command back into the code base.  This allows the
   extraction of the YAML information from a gem (which seems important
   to some on the mailing list).

* Renamed the BaseCommand to HelpCommand (since that's what it did
   anyways).  Reworked all the help commands work uniformly.  Added
   "help commands", and "help version" options.

* Changed the user interaction implementation to be based on an object
   that can be switched, rather than re-writing methods and trapping
   them with "when_invokes".  Updated the tests to use MockGemUI.

* Fixed "old data in yaml" bug described above.

* Made code that tried to remove app.cmd files fail silently if app.cmd
   is not there (which it ain't on Linux!).  This was in the uninstall

* Allowed build to take a straight YAML file as well as a gemspec.

* Version numbers are now automatically linked to the Rakefile.
   This allows you to change the version in one place and rake will
   automatically pick it up.

I'm off to work on documentation now.  Feedback is desired.

-- Jim Weirich    jim at weirichhouse.org     http://onestepback.org
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

More information about the Rubygems-developers mailing list