Dist::Zilla is Sad or is that Happy?

Sad day here at the Dist-pen.

Today I awoke still having nagging doubts about putting a copy of 'Database::Accessor::DAD::Test' directly into 'Test::Database::Accessor::Utils'. It did get all my tests to run correctly but it still was a cheat or a kludge at best.

So today I did build and then installed 'Database::Accessor' on my Ubuntu box as I wanted to see if I could get this little script;

use Database::Accessor;
my $in_hash = {
    view     => { name => 'People' },
    elements => [{name => 'first_name',
                            view => 'People'}, ],
my $da = Database::Accessor->new($in_hash);
my $return_str = {};
my $data       = Data::Test->new();
$da->retrieve( $data, $return_str );
  package Data::Test;
  use strict;

  sub new {
    my $class = shift;

    my $self = {};
    bless( $self, ( ref($class) || $class ) );

    return ($self);

to run. As you see I had to add in a 'Data::Test' package but this will still not run as I have no 'DAD' for it. To fix this I did a bad thing, added the 'Database::Accessor::DAD::Test' class that is in my 't/lib' dir, directly onto my installed perl, it is a good thing to have full 'sudo 'rights sometimes.

What I was trying to simulate was an installed Database::Accessor and an Installed DAD.

My first try and I got;

 perl dad.pl
RETRIEVE No Database::Accessor::Driver loaded for Data::Test Maybe you have to install a Database::Accessor::DAD::?? for it? At …
so all the way back to square one.

Undaunted, I decided to give one last try at getting the embedded classes to work, as I know this embedded architecture does in other modules. Now, I could of taken the other path and try to separate out the embedded classes again, as I did save that effort a few days ago. However, I still had allot of work to do to on them. I know I would have to split the Types role into two or more roles and then change how I build up the various classes from new set of base classes and roles. Not something I wanted to do.

First step was to clean up my perl by getting rid of all the Accessor code I hacked in, and then I got rid of the 'Database::Accessor::DAD::Test' in the Utils class. The I went back and had a good read of the 'Requires' section of the Perl POD.

Didn't get much out of that except that 'requires' checks to see if the file the class represents is in the path which is what I want.

I went back to the original code that I got the '_loadDADClassesFromDir' sub from. but this time looked a little deeper into that system and found that the lib paths in that modules where pre-set so that is why only

eval { 
   “requires  $classname”;
was working in that system the same reason why it was working for me on Windows. Then I realized I could repeat the little trick I did with 'Utils.pm' in Accessor.pm like this

-- eval {
--    “requires  $classname”;
-- }

++ eval qq{package
++     Database::Accessor::DAD::_ensure;
++        require $classname;    # load the driver
++     };

 if ($@) {
and I got

All tests successful.
Files=26, Tests=317, 33

So back to happy or is that angry or sad? I can never tell.


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