Skip Menu |

This queue is for tickets about the Config-Any CPAN distribution.

Report information
The Basics
Id: 30123
Status: resolved
Priority: 0/
Queue: Config-Any

People
Owner: bricas [...] cpan.org
Requestors: cpan [...] fireartist.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: RFC: multiple yaml documents in a single file
YAML supports multiple documents in a single file (with the following syntax) --- document: one --- document: two This is supported by both YAML and YAML::Syck. However, only the first document in any file is available via Config::Any. I propose changing the behaviour so that if a document contains multiple streams, the config returned by load_files() is an arrayref containing all documents. Currently, the above file would return: $config->[0]->{filename} = { document => 'one' } I suggest it should be: $config->[0]->{filename} = [ { document => 'one' }, { document => 'two' }, ]; Would you accept a patch implementing this?
Subject: Re: [rt.cpan.org #30123] RFC: multiple yaml documents in a single file
Date: Sat, 20 Oct 2007 04:52:22 +0100
To: Carl Franks via RT <bug-Config-Any [...] rt.cpan.org>
From: Matt S Trout <dbix-class [...] trout.me.uk>
On Fri, Oct 19, 2007 at 10:35:12AM -0400, Carl Franks via RT wrote: Show quoted text
> > Fri Oct 19 10:35:10 2007: Request 30123 was acted upon. > Transaction: Ticket created by CFRANKS > Queue: Config-Any > Subject: RFC: multiple yaml documents in a single file > Broken in: (no value) > Severity: Normal > Owner: Nobody > Requestors: cpan@fireartist.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=30123 > > > > YAML supports multiple documents in a single file (with the following > syntax) > > --- > document: one > > --- > document: two > > This is supported by both YAML and YAML::Syck. > However, only the first document in any file is available via Config::Any. > > I propose changing the behaviour so that if a document contains multiple > streams, the config returned by load_files() is an arrayref containing > all documents. > > Currently, the above file would return: > > $config->[0]->{filename} = { document => 'one' } > > I suggest it should be: > > $config->[0]->{filename} = [ > { document => 'one' }, > { document => 'two' }, > ]; > > Would you accept a patch implementing this?
How can this be done without breaking backward compatibility? -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Director http://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
On Fri Oct 19 23:52:55 2007, dbix-class@trout.me.uk wrote: Show quoted text
> > How can this be done without breaking backward compatibility?
Matt - you seem to get everywhere! I had intended (but forgot to state) that the returned value would be an arrayref only if there were multiple YAML documents in the file. For existing single-document files, the user would see no change. I expect individual users of Config::Any to decide whether they wish to add support for multiple files to their code.
From: develop [...] traveljury.com
Show quoted text
> > I had intended (but forgot to state) that the returned value would be an > arrayref only if there were multiple YAML documents in the file. > For existing single-document files, the user would see no change. > I expect individual users of Config::Any to decide whether they wish to > add support for multiple files to their code.
It may be of interest to you that Config::Merge handles this already. (However, Config::Merge is meant for bigger configuration trees than Config::Any, so this may not be appropriate for you.) After loading your config tree, the data is all stored in a hash, but with the directory and file names as keys. So if your file 'my_list.yaml' contains several YAML streams, then the key would be 'my_list' and the value would be an array ref containing the various streams.
From: BRICAS [...] cpan.org
On Fri Oct 19 10:35:10 2007, CFRANKS wrote: Show quoted text
> YAML supports multiple documents in a single file (with the following > syntax)
[* SNIP *] Show quoted text
> Would you accept a patch implementing this?
To all concerned, this has been implemented in the latest Config::Any dev release (0.09_02 at the time of this message), please test. -Brian
Config::Any 0.10 is now on CPAN.