App-cpanminus
view release on metacpan or search on metacpan
lib/App/cpanminus/fatscript.pm view on Meta::CPAN
=item from_prereqs
$file = Module::CPANfile->from_prereqs({
runtime => { requires => { DBI => '1.000' } },
});
Creates a new Module::CPANfile object from prereqs hash you can get
via L<CPAN::Meta>'s C<prereqs>, or L<CPAN::Meta::Prereqs>'
C<as_string_hash>.
# read MYMETA, then feed the prereqs to create Module::CPANfile
my $meta = CPAN::Meta->load_file('MYMETA.json');
my $file = Module::CPANfile->from_prereqs($meta->prereqs);
# load cpanfile, then recreate it with round-trip
my $file = Module::CPANfile->load('cpanfile');
$file = Module::CPANfile->from_prereqs($file->prereq_specs);
# or $file->prereqs->as_string_hash
=item prereqs
Returns L<CPAN::Meta::Prereqs> object out of the parsed cpanfile.
=item prereq_specs
Returns a hash reference that should be passed to C<< CPAN::Meta::Prereqs->new >>.
=item features
Returns a list of features available in the cpanfile as L<CPAN::Meta::Feature>.
=item prereqs_with(@identifiers), effective_prereqs(\@identifiers)
Returns L<CPAN::Meta::Prereqs> object, with merged prereqs for
features identified with the C<@identifiers>.
=item to_string($include_empty)
$file->to_string;
$file->to_string(1);
Returns a canonical string (code) representation for cpanfile. Useful
if you want to convert L<CPAN::Meta::Prereqs> to a new cpanfile.
# read MYMETA's prereqs and print cpanfile representation of it
my $meta = CPAN::Meta->load_file('MYMETA.json');
my $file = Module::CPANfile->from_prereqs($meta->prereqs);
print $file->to_string;
By default, it omits the phase where there're no modules
registered. If you pass the argument of a true value, it will print
them as well.
=item save
$file->save('cpanfile');
Saves the currently loaded prereqs as a new C<cpanfile> by calling
C<to_string>. Beware B<this method will overwrite the existing
cpanfile without any warning or backup>. Taking a backup or giving
warnings to users is a caller's responsibility.
# Read MYMETA.json and creates a new cpanfile
my $meta = CPAN::Meta->load_file('MYMETA.json');
my $file = Module::CPANfile->from_prereqs($meta->prereqs);
$file->save('cpanfile');
=item merge_meta
$file->merge_meta('META.yml');
$file->merge_meta('MYMETA.json', '2.0');
Merge the effective prereqs with Meta specification loaded from the
given META file, using CPAN::Meta. You can specify the META spec
version in the second argument, which defaults to 1.4 in case the
given file is YAML, and 2 if it is JSON.
=back
=head1 AUTHOR
Tatsuhiko Miyagawa
=head1 SEE ALSO
L<cpanfile>, L<CPAN::Meta>, L<CPAN::Meta::Spec>
=cut
MODULE_CPANFILE
$fatpacked{"Module/CPANfile/Environment.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'MODULE_CPANFILE_ENVIRONMENT';
package Module::CPANfile::Environment;
use strict;
use warnings;
use Module::CPANfile::Prereqs;
use Carp ();
my @bindings = qw(
on requires recommends suggests conflicts
feature
osname
mirror
configure_requires build_requires test_requires author_requires
);
my $file_id = 1;
sub new {
my($class, $file) = @_;
bless {
file => $file,
phase => 'runtime', # default phase
feature => undef,
features => {},
prereqs => Module::CPANfile::Prereqs->new,
mirrors => [],
}, $class;
}
sub bind {
( run in 1.166 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )