lib/App/Greple/perl.pm

filter: Statementstmt 58.0% 29 / 50 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 53.7% 36 / 67 CC 4 SCAR 15.2
CC
4
Cov
52%
part
12.0
setup
6.0
BEGIN
1.0
CRAP 4.6
« lib/App/Greple/PgpDecryptor.pm ↑ Summary lib/App/Greple/Pattern.pm »
1 =head1 NAME
2  
3 perl - Greple module for perl script
4  
5 =head1 SYNOPSIS
6  
7 greple -Mperl [ options ]
8  
9 =head1 SAMPLES
10  
11 greple -Mperl option pattern
12  
13 --code search from perl code outisde of pod document
14 --pod search from pod document
15 --comment search from comment part
16 --data search from data part
17 --doc search from pod and comment
18 --allpart search from all sections
19  
20 greple --colordump file
21  
22 =head1 DESCRIPTION
23  
24 Sample module for B<greple> command supporting perl script.
25  
26 =cut
27  
28 package App::Greple::perl;
29  
30 1 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use App::Greple::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use App::Greple::Regions qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
35 REGION_INSIDE REGION_OUTSIDE
36 REGION_UNION REGION_INTERSECT
37 match_regions
38 select_regions
39 merge_regions
40 reverse_regions
41 1 );
42 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
45 1 our @EXPORT = qw(part pod comment doc code);
46 1 our %EXPORT_TAGS = ( );
47 1 our @EXPORT_OK = qw();
48  
49 1 my %part;
50  
51 1 my $pod_re = qr{^=\w+(?s:.*?)(?:\z|^=cut\h*\n)}m;
52 1 my $comment_re = qr{^(?:\h*#.*\n)+}m;
53 1 my $data_re = qr{^__DATA__\n(?s:.*)}m;
54 1 my $empty_re = qr{^(?:\h*\n)+}m;
55  
56 0 ▶sub setup {
Subroutine setup: not called CC=2 SCAR=17.9
Pod undocumented
57 0 state $target = -1;
58 0 ▶ if ($target == \$_) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target == \$_) { } 0 0 0
59 0 return $target;
60 } else {
61 0 $target = \$_;
62 }
63 0 my @pod = match_regions(pattern => $pod_re);
64 0 my @comment = select_regions([ match_regions(pattern => $comment_re) ],
65 \@pod, REGION_OUTSIDE);
66 0 my @data = match_regions(pattern => $data_re);
67 0 my @empty = match_regions(pattern => $empty_re);
68 0 my @doc = merge_regions(@pod, @comment);
69 0 my @noncode = merge_regions(@doc, @data, @empty);
70 0 my @code = reverse_regions(\@noncode);
71 0 my @nondoc = reverse_regions(\@doc);
72 0 %part = (
73 pod => \@pod,
74 comment => \@comment,
75 doc => \@doc,
76 code => \@code,
77 data => \@data,
78 nondoc => \@nondoc,
79 noncode => \@noncode,
80 empty => \@empty,
81 );
82 }
83  
84 0 ▶sub part {
Subroutine part: not called CC=3 SCAR=24.8
Pod undocumented
85 0 my %arg = @_;
86 0 ▶ my $file = delete $arg{&FILELABEL} or die;
Branch: 1 branch
BranchTrueFalseTotal
my $file = delete $arg{&FILELABEL} or die 0 0 0
87 0 ▶ setup and merge_regions do {
Branch: 1 branch
BranchTrueFalseTotal
setup() and merge_regions(do { map {@{$part{$_};};} grep({exists $part{$_};} grep({$arg{$_};} keys %arg)) }) 0 0 0
88 0 map { @{$part{$_}} }
89 0 grep { exists $part{$_} }
90 0 grep { $arg{$_} }
91 keys %arg;
92 };
93 }
94  
95 1 1;
96  
97 __DATA__
« lib/App/Greple/PgpDecryptor.pm ↑ Summary lib/App/Greple/Pattern.pm »