.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Module::CPANfile 3pm" .TH Module::CPANfile 3pm "2018-05-17" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Module::CPANfile \- Parse cpanfile .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Module::CPANfile; \& \& my $file = Module::CPANfile\->load("cpanfile"); \& my $prereqs = $file\->prereqs; # CPAN::Meta::Prereqs object \& \& my @features = $file\->features; # CPAN::Meta::Feature objects \& my $merged_prereqs = $file\->prereqs_with(@identifiers); # CPAN::Meta::Prereqs \& \& $file\->merge_meta(\*(AqMYMETA.json\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Module::CPANfile is a tool to handle cpanfile format to load application specific dependencies, not just for \s-1CPAN\s0 distributions. .SH "METHODS" .IX Header "METHODS" .IP "load" 4 .IX Item "load" .Vb 2 \& $file = Module::CPANfile\->load; \& $file = Module::CPANfile\->load(\*(Aqcpanfile\*(Aq); .Ve .Sp Load and parse a cpanfile. By default it tries to load \f(CW\*(C`cpanfile\*(C'\fR in the current directory, unless you pass the path to its argument. .IP "from_prereqs" 4 .IX Item "from_prereqs" .Vb 3 \& $file = Module::CPANfile\->from_prereqs({ \& runtime => { requires => { DBI => \*(Aq1.000\*(Aq } }, \& }); .Ve .Sp Creates a new Module::CPANfile object from prereqs hash you can get via CPAN::Meta's \f(CW\*(C`prereqs\*(C'\fR, or CPAN::Meta::Prereqs' \&\f(CW\*(C`as_string_hash\*(C'\fR. .Sp .Vb 3 \& # read MYMETA, then feed the prereqs to create Module::CPANfile \& my $meta = CPAN::Meta\->load_file(\*(AqMYMETA.json\*(Aq); \& my $file = Module::CPANfile\->from_prereqs($meta\->prereqs); \& \& # load cpanfile, then recreate it with round\-trip \& my $file = Module::CPANfile\->load(\*(Aqcpanfile\*(Aq); \& $file = Module::CPANfile\->from_prereqs($file\->prereq_specs); \& # or $file\->prereqs\->as_string_hash .Ve .IP "prereqs" 4 .IX Item "prereqs" Returns CPAN::Meta::Prereqs object out of the parsed cpanfile. .IP "prereq_specs" 4 .IX Item "prereq_specs" Returns a hash reference that should be passed to \f(CW\*(C`CPAN::Meta::Prereqs\->new\*(C'\fR. .IP "features" 4 .IX Item "features" Returns a list of features available in the cpanfile as CPAN::Meta::Feature. .IP "prereqs_with(@identifiers), effective_prereqs(\e@identifiers)" 4 .IX Item "prereqs_with(@identifiers), effective_prereqs(@identifiers)" Returns CPAN::Meta::Prereqs object, with merged prereqs for features identified with the \f(CW@identifiers\fR. .IP "to_string($include_empty)" 4 .IX Item "to_string($include_empty)" .Vb 2 \& $file\->to_string; \& $file\->to_string(1); .Ve .Sp Returns a canonical string (code) representation for cpanfile. Useful if you want to convert CPAN::Meta::Prereqs to a new cpanfile. .Sp .Vb 4 \& # read MYMETA\*(Aqs prereqs and print cpanfile representation of it \& my $meta = CPAN::Meta\->load_file(\*(AqMYMETA.json\*(Aq); \& my $file = Module::CPANfile\->from_prereqs($meta\->prereqs); \& print $file\->to_string; .Ve .Sp 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. .IP "save" 4 .IX Item "save" .Vb 1 \& $file\->save(\*(Aqcpanfile\*(Aq); .Ve .Sp Saves the currently loaded prereqs as a new \f(CW\*(C`cpanfile\*(C'\fR by calling \&\f(CW\*(C`to_string\*(C'\fR. Beware \fBthis method will overwrite the existing cpanfile without any warning or backup\fR. Taking a backup or giving warnings to users is a caller's responsibility. .Sp .Vb 4 \& # Read MYMETA.json and creates a new cpanfile \& my $meta = CPAN::Meta\->load_file(\*(AqMYMETA.json\*(Aq); \& my $file = Module::CPANfile\->from_prereqs($meta\->prereqs); \& $file\->save(\*(Aqcpanfile\*(Aq); .Ve .IP "merge_meta" 4 .IX Item "merge_meta" .Vb 2 \& $file\->merge_meta(\*(AqMETA.yml\*(Aq); \& $file\->merge_meta(\*(AqMYMETA.json\*(Aq, \*(Aq2.0\*(Aq); .Ve .Sp Merge the effective prereqs with Meta specification loaded from the given \s-1META\s0 file, using CPAN::Meta. You can specify the \s-1META\s0 spec version in the second argument, which defaults to 1.4 in case the given file is \s-1YAML,\s0 and 2 if it is \s-1JSON.\s0 .IP "options_for_module" 4 .IX Item "options_for_module" .Vb 1 \& my $options = $file\->options_for_module($module); .Ve .Sp Returns the extra options specified for a given module as a hash reference. Returns \f(CW\*(C`undef\*(C'\fR when the given module is not specified in the \f(CW\*(C`cpanfile\*(C'\fR. .Sp For example, .Sp .Vb 3 \& # cpanfile \& requires \*(AqPlack\*(Aq, \*(Aq1.000\*(Aq, \& dist => "MIYAGAWA/Plack\-1.000.tar.gz"; \& \& # ... \& my $file = Module::CPANfile\->load; \& my $options = $file\->options_for_module(\*(AqPlack\*(Aq); \& # => { dist => "MIYAGAWA/Plack\-1.000.tar.gz" } .Ve .SH "AUTHOR" .IX Header "AUTHOR" Tatsuhiko Miyagawa .SH "SEE ALSO" .IX Header "SEE ALSO" cpanfile, CPAN::Meta, CPAN::Meta::Spec