Re: [Module-build-general] read_config()?
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-05-23 21:10:48
|
On Friday, May 23, 2003, at 06:57 AM, Scott Bolte wrote:
> On Thu, 22 May 2003 09:42:24 -0500, Ken Williams wrote:
>> The META.yml is created when the distribution is created, i.e. right
>> before the distro is uploaded to CPAN or otherwise made available. It
>> does *not* get re-created when users download, build, and install the
>> module, because they don't typically run the 'distdir' action.
>
> In that case I may need a different approach. Among other
> things, I need to know how the user is configuring their
> installation.
And this is the stuff you're putting in the private data hash? I think
I'm starting to see what you mean.
One of the things I'd like to do with M::B in general (and I don't
think I've mentioned this anywhere yet) is to help people share data
among the various processes that collaborate when building & installing
the module. This includes the PL_files, the test scripts, and the
Module::Build module/subclass itself. My dream idea is that you could
just do
my $m = Module::Build->instance();
or
my $m = Module::Build->current();
or something like that in the various scripts, and you'd get a handle
to the M::B object (or a reasonable facsimile thereof) whenever you
needed it. I haven't thought through what it would take to make this
happen, though.
Until this happens, Scott, you'll probably have to write the
information to a temporary file and read that file when you need the
information. You could do something like the following in a M::B
subclass:
my $file = $self->config_file('module_data');
my $fh = IO::File->new(">> $file") or die "Can't write to $file: $!";
print $fh Data::Dumper::Dump($whatever_config_information);
close $fh;
and then in your PL files:
my $file = File::Spec->catfile('_build', 'module_data');
my $fh = IO::File->new($file) or die "Can't read $file: $!";
my $whatever_config_information = eval do {local $/; <$fh>};
close $fh;
-Ken
|