[code-review] CPAN-Metadata

"Randy W. Sims" <RandyS-QFbi/[email protected]> Sat, 14 Feb 2004 12:57:32 -0500
Newsgroups gmane.comp.lang.perl.code-review-ladder
Message-ID <[email protected]>
<http://www.thepierianspring.org/CPAN-Metadata-0.00_01.tar.gz>

I'm working on a module to read, write, and validate metadata (META.yml) 
of the type generated by Module::Build, MakeMaker, and Module::Install.

I still have a lot of work to do on it, but I'm looking for some advice 
on cleaning up some duplicated code. The module has an AUTOLOAD routine 
that uses three methods (_mk_scalar_accessor(), _mk_array_accessor(), 
_mk_hash_accessor()). The code is almost identical between these 
methods, and I'd like to put them into a single method if possible. Is 
there any way other than using a giant eval?

Also, what do you think of the model? Specifications are stored in files 
in a CPAN/Metadata/Spec/ with names of the form 1R0.pm which would be 
for version 1.0. Each version is a subclass of those that come before. 
There is one main method that returns a list of valid attributes, its 
type, and whether it's required. For each attribute there can be two 
methods; each named after the attribute with a prefiex of 'V_' or 'C_'. 
'V_' methods are for validating the attributes data. 'C_' methods are 
for changes that will eventually lead to incompatibility in future 
versions. For example, 'C_' methods might emit a deprication warning or 
if an attribute is changing names (ex no_index => private), it might 
emit a warning and possibly remap it to the appropriate name.

The main module, CPAN::Metadata, will be a (hopefully) static engine 
when done - all changes should be possible by modifying the spec files. 
It does not require YAML for creating a metadata object, validating, or 
writing. YAML.pm will only be required for reading. When you use this 
module, you can request it be validated with any of the supported specs 
(ex 'use CPAN::Metadata spec => 1.0;'). If no version is specified it 
will use the highest version supported.

The code is at:
<http://www.thepierianspring.org/CPAN-Metadata-0.00_01.tar.gz>

Thanks,
Randy.