Jekyll Simple Stat has grown to Raku!

During the New Year’s holiday, I made different changes to my very simple Perl 5 script that I use to generate statistical data about my blog.
While doing such changes, I thought about how to implement a single year generation, because after all you should not re-generate every time all the blog stats. I ended up to the conclusion that the current data structure in my script was too simple to easily process a single year, and therefore some more complex object was required.
Now, since with the new year I started again reading the excellent brian d foy books on Perl 6 (that I read on December 2018), I decided to try to implement it in Raku. After all, how long could it take?

I had to work over for a few days, since it was not clear which classes have to do what, and effectively I changed the internal data structure a couple of times; this is a normal process if you start from scratch and it is the beauty of working with a dynamic language!

And so it comes today: my Raku version is now merged and available!

This new version has several new features and drawbacks, so more in general is different in concept and implementation from the old one. The Perl 5 version of this application will be no more mantained, or better, it could be I will have time to rewrite it to be consistent with the Raku version, but I don’t think this will happen in the near future.

Features of the Raku Version

The new version is much more consistent in the file naming, and in particular tends to store all the resulting files and images into a subdirectory stats.
The program file name itself is much shorter, going from to jss.p6.
The application accepts only one mandatory argument, that is the home folder of the blog, so that all other directories like the images one, the include ones and so on, are automatically computed by the script (let’s call it as convention over configuration).

There is another important parameter that allows you to optionally indicate the year you want to generate. This is useful to make the whole generation a lot easier, since you probably don’t want to modify every time the stats about past years.
In particular, the --year parameter accepts either a numberic year or a special keyword like:
  • current to generate only the current year (as from the system clock);
  • previous or last to generate only the previous here (useful across the year boundary).

    Moreover, the program provides a quite extensive online help that can be accessed via the --help parameter and has been implemeted by means of a multi MAIN entry point.
    Since this version supports partial generation of statistical data, the generated files have been splitted in different files per year. This can be a drawback, since now there’s much more stuff to include in the markdown final result, but allows for a fine grain tuning of every report. Moreover, this distinction allows for every single section generated to include a timestamp about the generation, that can effectively happen at different times.

Possible Future Development

In the future, it could make sense to remove the hard-coded GNUPlot templates from the script and use some templating system to generate them.
Another possible enhancement would be a parallel execution, with one Promise to execute a single year.

Let’s see what comes to mind (and how many time do I have).

The article Jekyll Simple Stat has grown to Raku! has been posted by Luca Ferrari on January 26, 2020