jump to navigation

Minitar, Ruwiki, and Commands
Tuesday, 7 September 2004

Posted by austin in: Archive, Ruby, Ruwiki, trackback

I mentioned last week that I had detoured into Mauricio’s rpa-base code for packaging code. I was all set to finish the work on a deployable Ruwiki, complete with this code included in the release, when I realised: “that’s dumb.” Why was I going to release something that could and should be an independent library embedded in Ruwiki, when the whole point of the exercise is to make Ruwiki a good RubyGem and RPA package that doesn’t include things which are logically separate.

It wasn’t as if I weren’t going to release Minitar as a separate package; I said that I would, last week. I just realised that doing it earlier was more important than doing it later and getting Ruwiki out quickly. Doing this also helped me find an answer to the next phase of Ruwiki development, too (following the deployment release).

While looking around at options for how to present the UI for the Ruwiki deployment utility and the minitar utility, I looked at the RubyGems code that emulates the cvs command-line in many ways. This made a lot
of sense, to me, so I created CommandPattern:

class CommandPattern
  class AbstractCommandError < Exception; end
  class UnknownCommandError < RuntimeError; end
  class CommandAlreadyExists < RuntimeError; end

  class << self
    def add(command); ...; end
    def <<(command); ...; end
    attr_accessor :default
    def command?(command); ...; end
    def command(command); ...; end
    def [](cmd); ...; end
    def default_ioe; ...; end
  end

  def [](args, opts = {}, ioe = {}); ...; end
  def name; ...; end
  def call(args, opts = {}, ioe = {}); ...; end
  def help; ...; end
end

It seems to me that this is exactly the same pattern as I need to deal with for Actions in Ruwiki. Okay, so there are differences -- but not as many as I had initially thought. The amount of code to be reused, to be quite honest, is low, but the concept reuse is high. It's very cool, to say the least.

Follow-up

With the release of minitar, the examples originally given for deployment could become:

% minitar extract ruwiki-0.8.0.tar.gz
% cd ruwiki-0.8.0
% ruwiki_servlet

Comments

Sorry, comments are closed for this entry