New Blog Tooling

To help out with the new blogging system I had fun hacking up some support scripts. I tried a new style this time, one base script and a bunch of plugins, so I do things now, as

$ blog create new_blog_tooling
$ blog edit new_blog_tooling

Which is kind of shiny. I did it in ruby as I wanted to just get it done, but as I futzedI realized I really wanted a module system more like Lua or Erlang’s - I didn’t want to know the module name, but wanted to access stuff on it.

The closest I got was a pretty gross eval hack, which looks like

def load_command command
  it =, "#{command}.rb")) do |f|
  ms =<<-EOM do

Which creates an instance of an anonymous class and lets me call methods on it, the “plugins” then are just bare method definitions, like

def execute
  draft_dir = File.join(BaseDir, "_drafts")
  name = ARGV[1]
  exec "#{ENV['EDITOR']} #{File.join(draft_dir, "#{name}.textile") }"

def usage

def help
  "open <name> in $EDITOR"

Which are usd to generate help and execute the actual commands,

$ blog -h
Usage: blog command [additional]

  blog create <name>
    creates a new draft with name <name>

  blog drafts 
    list all drafts

  blog edit <name>
    open <name> in $EDITOR

  blog kill <name>
    destroy the draft <name>


Annoyed at having to use an eval hack, but hey, it works.