Dist::Zilla: Feeling Better after Smoke

Today in the Dist-Pen I am going to have another crack at a different Versioning technique.

In my last post I had a look at using Dist::Zilla::Plugin::PkgVersion and I found it very useful but in the end I ran into a problem with putting all my Database::Accessor classes into my Accessor.pm file.

I wanted to see if I could have differing versions within the same file and the short answer was 'No' but the long answer was 'Yes'. I did play about with 'Dist::Zilla::Role::PPI' to see if I could adjust it to what I wanted it to do.

Well after a little while of poking about I did manage to get it to work the way I wanted but it was a hard-coded Kludge which I think could evolve into a patch. Now before I started to go down that rabbit hole I noticed there was an IRC for Dist::Zilla so I asked a quick question there before I created the patch.

After a little while on the IRC and some good advice I quickly dropped the idea of patching PPI as the majority of users will never want or use the feature and will most likely break any number of other peoples thinies.

Taking another track from a suggestion from the IRC I gave 'Dist::Zilla::Plugin::RewriteVersion' along with 'Dist::Zilla::Plugin::BumpVersionAfterRelease'. I am not going to bore you with another run of minor changes to my '.ini' file and many lines form my 'dzil build' results, I am just going to tell you the end result. I did manage to get what I wanted to happen but only just.

I was able to get my revsioning to work for the classes but I had all the version numbers for the embedded class will have to be handled by hand. As well the style of version;

our $VERSION = '0.010';
was not in-keeping with what I wanted to use namely;;

$Database::Accessor::VERSION = "0.01";
In the end I think I found a better solution and it involves some changes to my Accesor.pm. I started out wanting to have all the differing classes and roles, both the embedded and the ones in separate files, to have their own version, That requirement was a hold over from the earlier pre-Moose version where there was a need for some parts to have different versions, mostly the authentication code. That is not longer a requirement as I do not see how anyone they could invoke a Version 1.1 Accessor.pm with a version 1.0 Element class especially as they are in the same file.

Now that leads me with a dilemma if I do want to use PkgVersion I will get the versions on those embedded classes but I there is a solution in yet another plug-in called 'SurgicalPkgVersion'

This plug-ing works with PkgVestion but allows me to set exactly what is going to be versioned. To start I add in that package to my '.ini'

die_on_existing_version = 1
die_on_line_insertion = 1
Now I have to add this hint Into the file I want versioned I had to add this line

    package Database::Accessor;
++# Dist::Zilla: +PkgVersion
reran my 'dzil build' and got exactly the same results as the first time I ran it. All of my embedded classes had a version.

  package Database::Accessor::Roles::Alias;
$Database::Accessor::Roles::Alias::VERSION = '0.01';
Well the plugin did give me a little hope as it had one more little part. If I used

 package Database::Accessor::Roles::Alias;
# Dist::Zilla: -PkgVersion
It should skip the package. So I added that in on my embedded classes and rebuit but got the same result, but then I noticed

[PkgVersion] skipping private package Database::Accessor::Base in lib/Database/Accessor.pm
Hmm. A quick look at the results for that

# Dist::Zilla: -PkgVersion

hmm no version and checking the source file I noticed all the other embedded classes did not have that line feed there, I must of left it in by mistake, and for once a typo pays off. Funny thing is I had my embedded classes set up like this from the very beginning, it is only when I did a perl tidy on the file did they go back to a single line.

Needless to say in the end my '.ini' did not need that 'SurgicalPkgVersion' plugin, 'PkgVersion' does what I want as long as I do that line break in there.

I double checked the pod and I didn't see that anywhere so I guess another undocumented feature?


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