bin/markpod

filter: Statementstmt 79.0% 34 / 43 Branchbran 36.6% 11 / 30 Conditioncond 25.0% 3 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 54.6% 53 / 97 CC 1 SCAR 0.0
CC
1
Cov
56%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Markdown/Pod/Embed/Constant.pm ↑ Summary
1 #!/usr/bin/env perl
2  
3 #
4 # This file is part of Markdown::Pod::Embed.
5 #
6 # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>.
7 #
8 # This is free software; you can redistribute it and/or modify it under
9 # the same terms as the Perl 5 programming language system itself.
10 #
11 # Full license text is available at:
12 #
13 # <http://dev.perl.org/licenses/>
14 #
15  
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Getopt::Long qw(GetOptions);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Markdown::Pod::Embed;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 $VERSION='1.012';
23  
24 1 my %opt;
25 GetOptions(
26 'inplace|i' => \$opt{'inplace'},
27 'recursive|recurse|r' => \$opt{'recursive'},
28 'dry-run' => \$opt{'dry_run'},
29 'nobackup' => \$opt{'nobackup'},
30 'dialect=s' => \$opt{'dialect'},
31 'extract-markdown|extract_markdown' => \$opt{'markdown'},
32 'extract-pod|extract_pod' => \$opt{'pod'},
33 'version' => \$opt{'version'},
34 1 ▶ 'help' => \$opt{'help'},
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("inplace|i", \$opt{"inplace"}, "recursive|recurse|r", \$opt{"recursive"}, "dry-run", \$opt{"dry_run"}, "nobackup", \$opt{"nobackup"}, "dialect=s", \$opt{"dialect"}, "extract-markdown|extract_markdown", \$opt{"markdown"}, "extract-pod|extract_pod", \$opt{"pod"}, "version", \$opt{"version"}, "help", \$opt{"help"}) or die "invalid options; use --help\n" 1 0 1
35 ) or die "invalid options; use --help\n";
36 1 ▶if ($opt{'help'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"help"}) 0 1 1
37 0 print "Usage: markpod [--inplace] [--recursive] [--dry-run] [--nobackup] FILE...\n";
38 0 print " markpod --extract-markdown|--extract-pod FILE\n";
39 0 exit 0;
40 }
41 1 ▶if ($opt{'version'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"version"}) 0 1 1
42 0 print "markpod $VERSION\n";
43 0 exit 0;
44 }
45 1 ▶die "supply a file or directory\n" unless @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV 0 1 1
46 1 ▶die "choose one extraction mode\n" if $opt{'markdown'} && $opt{'pod'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"markdown"} and $opt{"pod"} 0 1 1
Condition33%1/3
$opt{"markdown"} and $opt{"pod"}
!ll&&!rl&&r
100
MC/DC0%0/2
$opt{"markdown"} and $opt{"pod"}
$opt{"markdown"} $opt{"pod"}
Truth table33%1/3
A and B
A= $opt{"markdown"}B= $opt{"pod"}
ABresult
0X0
100
111
47 1 ▶die "extraction cannot update files\n" if $opt{'inplace'} && ($opt{'markdown'} || $opt{'pod'});
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"inplace"} and $opt{"markdown"} || $opt{"pod"} 0 1 1
Condition16%1/6
$opt{"inplace"} and $opt{"markdown"} || $opt{"pod"}
!ll&&!rl&&r
100
$opt{"markdown"} or $opt{"pod"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$opt{"inplace"} and $opt{"markdown"} || $opt{"pod"}
$opt{"inplace"} $opt{"markdown"} $opt{"pod"}
Truth table25%1/4
A and B or C
A= $opt{"inplace"}B= $opt{"markdown"}C= $opt{"pod"}
ABCresult
0XX0
1000
11X1
1011
48 1 ▶die "directories require --recursive\n" if !$opt{'recursive'} && grep { -d $_ } @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
if not $opt{"recursive"} and grep {-d $_;} @ARGV 0 1 1
Condition33%1/3
not $opt{"recursive"} and grep {-d $_;} @ARGV
!ll&&!rl&&r
010
MC/DC0%0/2
not $opt{"recursive"} and grep {-d $_;} @ARGV
not $opt{"recursive"} grep {-d $_;} @ARGV
Truth table33%1/3
not(A) and B
A= not $opt{"recursive"}B= grep {-d $_;} @ARGV
ABresult
0X0
100
111
49 1 my $file_ar=Markdown::Pod::Embed->discover(@ARGV);
50 1 ▶delete $opt{'dialect'} unless defined $opt{'dialect'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt{"dialect"} 1 0 1
51 1 my $processor_or=Markdown::Pod::Embed->new(\%opt);
52 1 foreach my $fn (@{$file_ar}) {
53 1 my $changed=$processor_or->process($fn);
54 1 ▶ next unless defined $changed;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $changed 0 1 1
55 1 ▶ if ($opt{'dry_run'}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($opt{'dry_run'}) { } 1 0 1
elsif ($opt{'markdown'}) { } 0 0 0
elsif ($opt{'pod'}) { } 0 0 0
elsif ($opt{'inplace'}) { } 0 0 0
56 1 ▶ print "$fn: ", ($changed ? 'would update' : 'unchanged'), "\n";
Branch: 1 branch
BranchTrueFalseTotal
$changed ? : 0 1 1
57 }
58 0 elsif ($opt{'markdown'}) { print $processor_or->markdown() }
59 0 elsif ($opt{'pod'}) { print $processor_or->pod() }
60 0 ▶ elsif ($opt{'inplace'}) { $processor_or->markpod_inplace_update($fn) if $changed }
Branch: 1 branch
BranchTrueFalseTotal
if $changed 0 0 0
61 0 else { print $processor_or->ppi_doc_or()->serialize() }
62 }
63 __END__
« blib/lib/Markdown/Pod/Embed/Constant.pm ↑ Summary