.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" 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 turned on, 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 .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Module::CPANfile 3pm" .TH Module::CPANfile 3pm "2014-08-29" "perl v5.20.1" "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 .SH "AUTHOR" .IX Header "AUTHOR" Tatsuhiko Miyagawa .SH "SEE ALSO" .IX Header "SEE ALSO" cpanfile, CPAN::Meta, CPAN::Meta::Spec