Re: [Module::Build] broken META.yml file
Status: Beta
Brought to you by:
kwilliams
From: Stephen A. <spa...@gm...> - 2006-05-16 12:55:31
|
Hi, I am happy to address any real issue that you've found. It appears you are reporting two issues. Please clarify if I am misunderstanding the issues you reported. 1. The Gantry distribution does "author" wrong I think I am doing this right. The fact that the two authors show up as one string is not a YAML or Module::Build::YAML problem. The "author" element is extracted from the "=3Dhead1 AUTHOR" section of "Gantry.pm" because "module_name =3D> 'Gantry'," is in Build.PL (and no "author" entry exists). Here are the relevant files. http://search.cpan.org/src/PHILCROW/Gantry-3.30/META.yml http://search.cpan.org/src/PHILCROW/Gantry-3.30/Build.PL http://search.cpan.org/src/PHILCROW/Gantry-3.30/lib/Gantry.pm The META.yml which comes with the Gantry-3.30 distribution was generated with Module::Build version 0.2611, without YAML.pm, and it creates illegal YAML (as you pointed out). So does the initial 0.28 which uses Module::Build::YAML. --- #YAML:1.0 name: Gantry version: 3.30 author: - Tim Keefer <tk...@gm...> Phil Crow <phi...@ya...> abstract: Web application framework for mod_perl, cgi, etc. license: perl generated_by: Module::Build version 0.2611, without YAML.pm On my system, I have YAML.pm installed, and a "./Build distmeta" creates: author: - |- Tim Keefer <tk...@gm...> Phil Crow <phi...@ya...> This is legal YAML (good) but still not the array that is desired (bad). It is also a bit nicer to look at than the output of Module::Build::YAML, but it is functionally equivalent (below). author: - "Tim Keefer <tk...@gm...>\nPhil Crow <phi...@ya...>" I don't know if somewhere else in Module::Build needs to do something different in scanning Gantry.pm (to get the desired arrayref), but Module::Build::YAML is behaving correctly (and creating the same result as YAML.pm). 2. It would be nicer if long text sections were formatted nicer I think the requirement that Module::Build::YAML is meeting is to produce valid YAML which works. Module::Build::YAML - Provides just enough YAML support so that Module::Build works even if YAML.pm is not installed I wanted to stay away from the many flavors of multi-line formatting which are available in the full YAML spec. However, I believe that Module::Build::YAML does work properly. Instead of text: |- YAML::Node is a class for generating and manipulating these containers. A YAML node (or ynode) is a tied hash, array or scalar. In most ways it behaves just like the plain thing. But you can assign and retrieve and YAML type tag URI to it. For the hash flavor, you can also assign the order that the keys will be retrieved in. By default a ynode will offer its keys in the same order that they were assigned. it produces text: "YAML::Node is a class for generating and manipulating these\ncontainers. A YAML node (or ynode) is a tied hash, array or\nscalar. In most ways it behaves just like the plain thing. But you\ncan assign and retrieve and YAML type tag URI to it. For the hash\nflavor, you can also assign the order that the keys will be\nretrieved in. By default a ynode will offer its keys in the same\norder that they were assigned." in a single line. This is uglier, but it is still functionally correct. If people think I need to implement the more aesthetically pleasing format, I will consider adding it. (I was considering implementing the Load() subroutine with the promise that Module::Build::YAML::Load() can read anything it can Dump(). I wanted to stay away from the fancy multi-line YAML formats to make parsing simpler.) Stephen On 5/15/06, Randy W. Sims <ml...@th...> wrote: > Stephen Adkins wrote: > > Hi, > > > > I wrote Module::Build::YAML. > > I offer these patches. > > > > Both of the previously mentioned broken YAML files were a > > result of embedded newlines. I opted to tackle newlines and > > all of the other special characters which I could find which > > YAML considers special. > > > > I think this version will be quite an improvement in terms of > > robustness in the presence of "odd" characters in the scalar > > values. I patched > > I'm not sure this is correct; although, it is much improved. The second > instance with the module 'Gantry' should have an 'author' node that is > an array containing 2 elements. With your patch, I untared Gantry and ran > > # ysh > ysh > <META.yml > YAML Error: Invalid element in map > Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT > Line: 6 > Document: 1 > at C:\devel\perl\5.8.7\site\lib/YAML.pm line 60 > ysh > :q > > Which is the original error. After running > > # Build.PL > [ignore output] > > # perl Build distmeta > Deleting Makefile.PL > Creating Makefile.PL > Deleting META.yml > Creating META.yml > > # ysh > ysh > <META.yml > $VAR1 =3D { > 'name' =3D> 'Gantry', > 'version' =3D> '3.30', > 'author' =3D> [ > 'Tim Keefer <tk...@gm...> > Phil Crow <phi...@ya...>' > ], > ... > }; > > Notice that author is an array with *one* element that is a multiline > string. > > In the other case, we probably have a problem up stream(???): I would > expect the abstract to be returned as a single string removing the > formatting from the pod. I.E. Single \n should be collapsed along with > surrounding whitespace, while \n\n should remain a paragraph break. > > But do notice that YAML.pm when give a string with embedded \n > characters writes the result out as verbatim text: > > use YAML; > require YAML::Node; > > my $data =3D { text =3D> > "YAML::Node is a class for generating and manipulating these > containers. A YAML node (or ynode) is a tied hash, array or > scalar. In most ways it behaves just like the plain thing. But you > can assign and retrieve and YAML type tag URI to it. For the hash > flavor, you can also assign the order that the keys will be > retrieved in. By default a ynode will offer its keys in the same > order that they were assigned." > }; > > my $node =3D YAML::Node->new($data); > print Dump $node; > > __END__ > > outputs: > --- > text: |- > YAML::Node is a class for generating and manipulating these > containers. A YAML node (or ynode) is a tied hash, array or > scalar. In most ways it behaves just like the plain thing. But you > can assign and retrieve and YAML type tag URI to it. For the hash > flavor, you can also assign the order that the keys will be > retrieved in. By default a ynode will offer its keys in the same > order that they were assigned. > > > Whereas the same text without embedded \n gets printed as: > --- > text: 'YAML::Node is a class for generating and manipulating these > containers. A YAML node (or ynode) is a tied hash, array or scalar. In > most ways it behaves just like the plain thing. But you can assign and > retrieve and YAML type tag URI to it. For the hash flavor, you can also > assign the order that the keys will be retrieved in. By default a ynode > will offer its keys in the same order that they were assigned.' > > Regards, > Randy. > |