portable perspectives

a blog about programming, life, universe and everything

My Tiny DocTest for ruby

I believe that doctest for python is one of the best test libraries available, because it pushes the cost to develop functional tests to zero.

While I’m writing a dummy object persistence layer I thought it would have been nice to have something like that, basically seeking some kind of literate testing process.

This is the first attempt at it (warning dirty, slow, duplicated code).

It somehow works, can be run from rcov/rake/ruby, loaded with multiple files, and allows writing nice tests like this one . As you can see in the code, everything that does not look like irb code is ignored, which allows adding comments, leave python code mixed with ruby, write formulas and so on.

The lib is really half-backed, for example you canì’t use multiline declarations in irb or print something to screen, but I think it is a nice small thing.

You can find a different take on sample/doc testing in manveru’s repository

See all comments

Using darcs with FTP and without SSH

darcs is my favourite Version Control System. I'm not chris and I have not tried a lot of them, but I just love darcs' cherry picking so everything that misses that is out of my list. Maybe monotone or subversion 1.5 would be interesting.

Anyway, my only issue with darcs is that it does not allow pushing changes to a dumb repository, where dumb means ftp.

Since I don't have ssh access on all my hostings I found the solution in sitecopy which is a nifty utility to keep a remote directory in sync with a local one by doing incremental uploads.

To use this simply install sitecopy (which is probably avilable through your linux/bsd flavour package manager) and create a file ~/.sitecopyrc with a content like this:


site myproject
  server  ftp.myserver.com
  remote  /www/darcs.myserver.com/myproject
  local   /path/to/local/repository
  username  joe
  password  123

and to create a directory ~/.sitecopy. The permission mask for the dir must be 0700 and for the rc file it must be 0600, otherwise sitecopy will complain about insecure files.

At this point you just need to init the remote repository by doing sitecopy --init myproject. It may take some time because the first time you'll be uploading all the old patches in the _darcs/ directory, but the next time you will do this, using sitecopy --update myproject it will be quite fast.

Obviously this approach works nicely only in a single-user environment, because if multiple users share the remote directory there will be inconsistencies, but it is useful to keep your copy of a projects' repository where you can have your patches and where you can point people that want them.

See all comments

Atom Threading Extension FeedFlare

As I was saying in the other article, I implemented a simple dynamic FeedFlare to show the number of comments in your feed, based on the Atom Threading Extensions. The flare provides a link to $yourPageUrl#comments, it could be made more modular if someone needs that.

Basically this means that you need a <link> in your atom feed with rel="replies" and thr:count="123". The flare is not really smart in that it does not take the xmlns declaration into account (yet) so declare it like xmlns:thr="http://purl.org/syndication/thread/1.0".

Experimentally, the flare is available for your own use by using the address:

http://flarez.riffraff.inf/ate/

Just add it through myfeeds->optimize->feedlare. Depending on load the flare may be cached for some hours so don't worry if you don't see updates immediately.

See all comments

How to add Atom Threading Extension to Mephisto

Mephisto, the software that I use for this blog is a great little work.

It doesn't do everything and more, but the default installation provides a very nice administration interface and the most useful functionalities of a blogging system, namely tagging, feeds, comments, and so on. it has a good themeing system, an extensible architecture and a lot of plugins.

The only thing that I believe is missing is a good plugin for syntax highlighting code. There are a couple of them but both support a very restricted set of grammars so I'm not really satisfied and I'm working on a plugin based on vim.

Back to the topic. I always liked FeedBurner's FeedFlares, especially the one that provides comment counting.

That flare is based on RSS' wfw:comments, and basically works by accessing the comment feed linked from the main one and parsing that.

The Atom Threading Extensions allow a more detailed control of this linkage between feeds, more metadata and in the specific, they allow the embedding of the comment count (not only comments, the correct word is "replies") in the main feed, freeing you from the need to parse another feed.

To add this to mephisto you need to change a couple of lines, it would be possible to repackage this as a plugin, but I don't have time to investigate that ATM. In case you want to use this hack, you can see the diff against svn HEAD here

See all comments

AddThis Social Bookmark Button