PGVersion: a class to manage PostgreSQL Version (strings) within a Perl 6 Program

As you probably already know, PostgreSQL has changed its versioning number scheme from a `major.major.minor` approach to a concise `major.minor` one. Both are simple enought to be evaluated with a regular expression, but I found myself wrinting the same logic over and over, so I decided to write a minimal class to do the job for me and provide several information.

Oh, and this is Perl 6 (that I'm still learning!).


The idea is to have something like the following working:


use Fluca1978::Utils::PostgreSQL::PGVersion;

for <10.1 11beta1 11.1 9.6.5 6.11> {
my $v = PGVersion.new: :version-string( $_ );
say "PostgreSQL version is $v";
say "or for short { $v.gist }";
say "and if you want a detailed version:\n{ $v.Str( True ) }";
say "URL to download: { $v.http-download-url }";
say '~~~~' x 10;
}

The class allows you to check the info, get the URL for the download, compare two different versions to see which one is newer, see if it is a beta, and so on.
Read more on this blog post.

Leave a comment

About Luca Ferrari

user-pic Perl and PostgreSQL passionate and advocate, Open Source human being since a while.