Re: [Module-build-general] read_config()?
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-05-21 15:09:32
|
On Tuesday, May 20, 2003, at 10:21 PM, Scott Bolte wrote:
> Is there any way to cleanly read the configuration information
> stored in _build/? I want to determine the version information,
> which I plan on storing in Build.PL, in another .PL file.
> The following construct is what I came up with:
>
> my $build = new Module::Build
> (
> dist_name => undef,
> dist_version => undef,
> );
> $build->read_config();
> printf("version is \"%s\".\n",
> $build->{properties}{dist_version});
>
> new() complained unless I called it with dist_name and
> dist_version. (It was also noisy on STDOUT, but that's a
> separate issue.)
>
> I could duplicate the code in read_config(), but I am loath
> to break encapsulation so blatantly.
If you have the META.yml file already created, you could just look for
a line matching /^version: (\S+)/ in it. That file is meant to be
publicly readable, and doing this kind of spot-reading without a full
YAML parser is very much supported.
If there's a timing issue I'm not considering, i.e. if the META.yml
file isn't created yet, then we might have to figure something else out.
Also, the new version of Module::Build (0.19) will have a method
$build->dist_version() that will return the dist_version directly
instead of doing $build->{properties}{dist_version}.
-Ken
|