| Test-LatestPrereqs documentation | Contained in the Test-LatestPrereqs distribution. |
Test::LatestPrereqs::ModuleBuild
my @requires = Test::LatestPrereqs::ModuleBuild->parse($build_pl);
This is used internally to parse Build.PL (with Module::Build) to get requirements.
parses Build.PL and returns a list of requirements.
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2009 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Test-LatestPrereqs documentation | Contained in the Test-LatestPrereqs distribution. |
package Test::LatestPrereqs::ModuleBuild; use strict; use warnings; use Carp; sub parse { my ($class, $file) = @_; my @requires; no warnings 'redefine'; local $INC{'Module/Build.pm'}; local *Module::Build::new = sub { my ($class, %args) = @_; foreach my $type (qw(requires build_requires recommends)) { foreach my $key (keys %{ $args{$type} || {} }) { push @requires, [ $key, $args{$type}->{$key} || 0 ]; } } bless {}, 'Test::LatestPrereqs::ModuleBuild::Fake'; }; local *Module::Build::subclass = sub { 'Module::Build' }; eval { package main; no strict; no warnings; local *CORE::GLOBAL::exit = sub {}; require "$file"; }; delete $INC{$file}; if ($@ && $@ !~ /did not return a true value/) { croak "Build.PL error: $@"; } return @requires; } package # Test::LatestPrereqs::ModuleBuild::Fake; sub DESTROY {} sub AUTOLOAD { shift } 1; __END__