Skip to content

Commit

Permalink
Workaround for bug in Parse::CPAN::Meta "YAML" parser
Browse files Browse the repository at this point in the history
The Parse::CPAN::Meta parser is used by the Test::CPAN::Meta module
that the Plugin::MetaTests plugin uses.

The parser is a extremely fragile parser and chokes with valid YAML,
like a single element list:

    author:
    - Pedro Melo <melo@cpan.org>
    generated_by: Dist::Zilla::Plugin::MetaYaml version 1.091260

We now flatten the author entry if it is a single element list.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
  • Loading branch information
melo committed May 9, 2009
1 parent 47a8b66 commit b44ba01
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/Dist/Zilla/Plugin/MetaYaml.pm
Expand Up @@ -34,6 +34,23 @@ sub gather_files {
$meta = Hash::Merge::Simple::merge($meta, $_->metadata)
for $self->zilla->plugins_with(-MetaProvider)->flatten;

# Flatten lists with a single element
# workaround for simplistic Parse::CPAN::Meta YAML parser
# used by Test::CPAN::Meta used by Plugin::MetaTests
# We limit this to the authors entry for now, although a general
# solution could be used
#
# while (my ($key, $value) = each %$meta) {
# if (ref($value) eq 'ARRAY' && @$value == 1) {
# $meta->{$key} = $value->[0];
# }
# }
if (exists $meta->{author}
&& ref($meta->{author}) eq 'ARRAY'
&& @{$meta->{author}} == 1) {
$meta->{author} = $meta->{author}[0];
}

my $file = Dist::Zilla::File::InMemory->new({
name => 'META.yml',
content => YAML::XS::Dump($meta),
Expand Down

0 comments on commit b44ba01

Please sign in to comment.