Dist::Zilla Plots Version

Even more POD here at the Dit-pen.

In my last postI wrote about the rather simple [Name] section today I am going to move onto something a little more complex the [Version] section.

[Version] does not produce a lot of POD just

=head1 VERSION

version 0.01

in the case of my distribution. It is getting that '0.01' from my 'dist.ini' file

major = 1
format = {{ sprintf('0.%02d',$major)}}

There are four attributes that I can play with on this 'section' plugin;

This works the same as the header in [name] so to make it the same as my last post I add this to my 'weaver.ini'

header = Version

and I now get this

=head1 Version

version 0.01

So nothing to complex there.

This attribute controls what is printed when the version is generated. Now we are getting into a little more complex use of the template. There are nine variables that you can use with this attribute. They are

  • v - The version (default)
  • V – The version with a '-TRIAL' suffix for when the release is a trial version
  • d – Used to put a data on your version with CLRD control
  • n – Adds in a new line
  • t - Adds in a tab
  • s – Adds in a space
  • r – The name of the Distribution (only works under Dis::Zilla)
  • m – The name of the 'package' if present
  • T – Trailing spaces

Now I have not gotten far enough into Dist::Zilla to do a trial release so lets just play with something easy. The way you reference one of the above variable is with a '%' so if I want my version to be something like this

ver. 0.01 database-accessor

All I would need to do in the 'weaver.ini' is

format = ver %v%s%r

and I would get this

=head1 Version

ver 0.01 Database-Accessor

You are able to enter more than one format line, so in my 'weaver.ini' I could do this

header = Version
format = ver %v%s%r
format = %m
format = %t Check out older version at …

I would get this

ver 0.01 Database-Accessor
Check out older version at …

so there you see the %r or name next to the %v then on line down %m my module name and then one more line that starts with a %t or tab.

The other two attributes are 'is_verbatim' which will include any white space found after the '=' and 'time_zone' which controls the time-zone for any date you might have in your version.

So that is 'Version' section in a nutshell.


Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations