TaskPipe/PodReader.pm

filter: Statementstmt 63.9% 39 / 61 Branchbran 10.0% 1 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 3 totaltotal 55.5% 50 / 90 CC 7 SCAR 18.6
CC
7
Cov
55%
format_error_message
20.0
message
6.0
read_pod
3.0
CRAP 6.4
« TaskPipe/ThreadManager.pm ↑ Summary TaskPipe/Tool/Command__OpenProxies.pm »
1 package TaskPipe::PodReader;
2  
3 42 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 42 ▶use Cwd 'abs_path';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 42 ▶use Pod::POM;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 42 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 42 ▶use POSIX qw(isatty);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 42 ▶use Module::Runtime 'require_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 42 ▶use Pod::Term;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 has settings => (is => 'rw', isa => __PACKAGE__.'::Settings', default => sub{
13 4668 ▶ my $module = __PACKAGE__.'::Settings';
Subroutine __ANON__: called CC=1 SCAR=0.0
14 4668 require_module( $module );
15 4668 $module->new;
16 42 });
17  
18  
19 sub read_pod{
20  
21 4473 ▶ my ($self,$module) = @_;
Subroutine read_pod: called CC=3 SCAR=11.1
Pod undocumented
22  
23 4473 ▶ confess "Need a module name" unless $module;
Branch: 1 branch
BranchTrueFalseTotal
unless $module 0 4473 4473
24  
25 4473 my $parser = Pod::POM->new;
26  
27 4473 ▶ $module ||= ref( $self );
Condition33%1/3
$module ||= ref $self
l!l&&r!l&&!r
447300
MC/DC0%0/2
$module ||= ref $self
$module ref $self
Truth table33%1/3
A ||= B
A= $moduleB= ref $self
ABresult
1X1
011
000
28 4473 require_module( $module );
29  
30 4473 my $filename = $module;
31 4473 my $delim = File::Spec->catdir('');
32 4473 $filename=~ s{::}{$delim}g;
33 4473 $filename.='.pm';
34  
35 4473 my $path = abs_path( $INC{ $filename } );
36 4473 my $pod = $parser->parse_file( $path );
37  
38 4473 return $pod;
39 }
40  
41  
42 sub message{
43 0 ▶ my ($self,$pod) = @_;
Subroutine message: not called CC=2 SCAR=17.9
Pod undocumented
44  
45 0 my $parser = Pod::Term->new;
46 0 $parser->globals({
47 max_cols => 76,
48 base_color => undef
49 });
50  
51 0 ▶ if (isatty(*STDOUT)){
Branch: 1 branch
BranchTrueFalseTotal
if (isatty(*STDOUT)) { } 0 0 0
52 0 $parser->prop_map( $self->settings->pod_format );
53 } else {
54 0 $parser->prop_map( $self->settings->pod_format_mono );
55 }
56  
57 0 $parser->parse_string_document( "=pod\n\n$pod\n\n=cut\n\n" );
58 }
59  
60  
61
62 sub format_error_message{
63 0 ▶ my ($self,$err) = @_;
Subroutine format_error_message: not called CC=4 SCAR=30.0
Pod undocumented
64  
65 0 my $trace;
66 my $at;
67  
68 0 ▶ if ( $err =~ /^\[/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($err =~ /^\[/) 0 0 0
69 0 ($err,$at,$trace) = $err =~ /\[([^\]]+?)\]\s*([^\n]+)\n(.*?)$/s;
70 }
71  
72 0 ▶ if ($trace){
Branch: 1 branch
BranchTrueFalseTotal
if ($trace) { } 0 0 0
73 0 $trace =~ s/^\s*//s;
74 0 $trace =~ s/\n\s*/\n\n/g;
75 0 $err .= "B<($at)>\n\nI<Stack trace follows (most recent call first):>\n\n$trace\n";
76 } else {
77  
78 0 $err = "B<$err";
79 0 $err =~ s/\s*$//s;
80  
81 0 ▶ if ( $err =~ /\n/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($err =~ /\n/) { } 0 0 0
82 0 $err =~ s/\n/>\nI<Stack trace follows (most recent call first):>\n/;
83 } else {
84 0 $err .= '>';
85 }
86 0 $err =~ s/\n\s*/\n\n/g;
87  
88 }
89  
90 0 return $err;
91 }
92  
93 =head1 NAME
94  
95 TaskPipe::PodReader - read POD for TaskPipe
96  
97 =head1 DESCRIPTION
98  
99 It is not recommended to use this module directly. See the general manpages for TaskPipe
100  
101 =head1 AUTHOR
102  
103 Tom Gracey <tomgracey@gmail.com>
104  
105 =head1 COPYRIGHT AND LICENSE
106  
107 Copyright (c) Tom Gracey 2018
108  
109 TaskPipe is free software, licensed under
110  
111 The GNU Public License Version 3
112  
113 =cut
114  
115 42 __PACKAGE__->meta->make_immutable;
116 42 1;
« TaskPipe/ThreadManager.pm ↑ Summary TaskPipe/Tool/Command__OpenProxies.pm »