[Module-build-checkins] Module-Build/lib/Module/Build Base.pm,1.379,1.380 Authoring.pod,1.6,1.7
Status: Beta
Brought to you by:
kwilliams
From: Randy W. S. <si...@us...> - 2005-01-24 22:01:32
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22921/lib/Module/Build Modified Files: Base.pm Authoring.pod Log Message: Added new method Module::Build::prepare_metadata() for authors to override in order to add custom fields to META.yml. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.379 retrieving revision 1.380 diff -u -d -r1.379 -r1.380 --- Base.pm 24 Jan 2005 03:41:58 -0000 1.379 +++ Base.pm 24 Jan 2005 21:59:59 -0000 1.380 @@ -2370,8 +2370,21 @@ require YAML; # We use YAML::Node to get the order nice in the YAML file. - my $node = YAML::Node->new({}); - + my $node = $self->prepare_metadata( YAML::Node->new({}) ); + + # YAML API changed after version 0.30 + my $yaml_sub = $YAML::VERSION le '0.30' ? \&YAML::StoreFile : \&YAML::DumpFile; + $self->{wrote_metadata} = $yaml_sub->($self->{metafile}, $node ); + + $self->_add_to_manifest('MANIFEST', $self->{metafile}); +} + +sub prepare_metadata { + my $self = shift; + my $node = shift; + + my $p = $self->{properties}; + foreach (qw(dist_name dist_version dist_author dist_abstract license)) { (my $name = $_) =~ s/^dist_//; $node->{$name} = $self->$_(); @@ -2380,17 +2393,13 @@ foreach (qw(requires recommends build_requires conflicts)) { $node->{$_} = $p->{$_} if exists $p->{$_} and keys %{ $p->{$_} }; } - + $node->{dynamic_config} = $p->{dynamic_config} if exists $p->{dynamic_config}; $node->{provides} = $self->find_dist_packages; $node->{generated_by} = "Module::Build version $Module::Build::VERSION"; - - # YAML API changed after version 0.30 - my $yaml_sub = $YAML::VERSION le '0.30' ? \&YAML::StoreFile : \&YAML::DumpFile; - $self->{wrote_metadata} = $yaml_sub->($self->{metafile}, $node ); - $self->_add_to_manifest('MANIFEST', $self->{metafile}); + return $node; } sub _read_manifest { Index: Authoring.pod =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Authoring.pod,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Authoring.pod 24 Jan 2005 21:43:16 -0000 1.6 +++ Authoring.pod 24 Jan 2005 22:00:16 -0000 1.7 @@ -963,6 +963,22 @@ will return C<undef> - there shouldn't be many unknown platforms though. +=item prepare_metadata() + +This method is provided for authors to override to customize the +fields of F<META.yml>. It is passed a YAML::Node node object which can +be modified as desired and then returned. Eg. + + package My::Builder; + use base 'Module::Build'; + + sub prepare_metadata { + my $self = shift; + my $node = $self->SUPER::prepare_metadata( shift ); + $node->{custom_field} = 'foo'; + return $node; + } + =item prereq_failures() Returns a data structure containing information about any failed |