Send in New Dist::Zilla!!
In the Dist-Pen today I am looking at another plugin to help with my many versioning woes.
In my last post I had a look at a Dist::Zilla plugin that helped me out with versioning my distributions. Today I am going to see if there is a plugin that will help me out with my Module versions as well. So a quick look about and I see we have a few options so I will start with the most likely candidate 'Dist::Zilla::Plugin::PkgVersion'
Like all the Dist::Zilla plugins I have used so for this one is quite simple; Just add
[PkgVersion]
in my '.ini' Now there are a number of attributes I can play with but before I do that lets see what I have I my Database::Accessor classes;
BEGIN {
$Database::Accessor::VERSION = "0.01";
}
All of them are in the same format as above and from what I have been reading over the past little while this is not 100% proper. Seems when I wrote up the initial code for this project I just copied over what the original code was using As that code had a 'DynaLoader' part, access to a custom 'c' authentication module, and the Moose version does not require it so I think I will take that out.
So after a few mins of cutting code out of my packages I added in this to my '.ini'
[AutoVersion]
major = 1
format = {{ sprintf('0.%02d',$major)}}
++[PkgVersion]
++die_on_existing_version = 1
++die_on_line_insertion = 1
now what the two attributes are suppose to do are stop if a version is present, this will check to ensure I got all my present VESRIONS out of there and the second will die if I do not have a blank line after the package statement,
And here we go;
dzil build
[DZ] beginning to build Database-Accessor
[PkgVersion] no blank line for $VERSION after package Database::Accessor::Base statement in lib/Database/Accessor.pm line 404
ok let me fix that, it is even nice enough to tell me what line number to go to;
dzil build
[DZ] beginning to build Database-Accessor
[PkgVersion] no blank line for $VERSION after package Database::Accessor::Roles::PredicateArray statement in lib/Database/Accessor.pm line 488
and another, now I will skip the few more duplicates I did find one file where I forgot to put in an initial version and finally it did find one of these
existing assignment to $VERSION in lib/Database/Accessor/Types.pm
though this time it did not tell me what line number.
So after that was all cleaned up and the build ran without a problem. I had a look at some of my Accessor packages that where under the 'Database-Accessor-0.01' folder and they all had the correct version inserted, as in this one
package Database::Accessor;
$Database::Accessor::VERSION = '0.01';
Now it wasn't not smart enough to stick in the little extra white-space I used before my package statement, but I can live with that. I also checked my source files under 'lib' and they where unaffected as one would expect.
From what I read the above will still work if I take out the 'die_on_line_insertion' but the consequence would be that the line number count from my source to my distribution would be off by at least one or in the case of Accessor.pm some 16 lines because of all the bundled packages. Something to think about when I finally get this linked up to a git repository.
One finale feature I really like is this plugin will ignore any package declaration that are not on one line. So If I have this
package
Database::Accessor::Base;
$Database::Accessor::Base::VERSION = '0.1';
It should skip the version though this does not work at all with 'die_on_existing_version' on or when you have classes bundled in the same pm file. Perhaps this is a bug or just not interned to work with munged files??
Leave a comment