Minimal/Domain.pm

filter: Statementstmt 85.0% 34 / 40 Branchbran 41.6% 5 / 12 Conditioncond 54.5% 6 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 80.0% 8 / 10 Podpod 83.3% 5 / 6 totaltotal 68.2% 58 / 85 CC 12 SCAR 19.5
CC
12
Cov
71%
configure
14.0
interpolate
3.1
init
2.0
CRAP 7.0
« Minimal.pm ↑ Summary Optional.pm »
1 # This code is part of Perl distribution Log-Report-Optional version 1.08.
2 # The POD got stripped from this file by OODoc version 3.04.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2013-2025 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11 #oodist: *** DO NOT USE THIS VERSION FOR PRODUCTION ***
12 #oodist: This file contains OODoc-style documentation which will get stripped
13 #oodist: during its release in the distribution. You can use this file for
14 #oodist: testing, however the code of this development version may be broken!
15  
16 package Log::Report::Minimal::Domain;{
17 4 our $VERSION = '1.08';
18 }
19  
20  
21 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 4 ▶use String::Print 'oo';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 #--------------------
27  
28 6 ▶sub new(@) { my $class = shift; (bless {}, $class)->init({@_}) }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
29 sub init($)
30 6 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=2 SCAR=7.1
Pod undocumented
31 6 ▶ $self->{LRMD_name} = $args->{name} or Log::Report::panic();
Branch: 1 branch
BranchTrueFalseTotal
$self->{"LRMD_name"} = $args->{"name"} or Log::Report::panic() 6 0 6
32 6 $self;
33 }
34  
35 #--------------------
36  
37 0 ▶sub name() { $_[0]->{LRMD_name} }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
38 0 ▶sub isConfigured() { $_[0]->{LRMD_where} }
Subroutine isConfigured: not called CC=1 SCAR=6.9
Pod documented
39  
40  
41  
42 sub configure(%)
43 1 ▶{ my ($self, %args) = @_;
Subroutine configure: called CC=9 SCAR=26.4
Pod documented
44  
45 1 ▶ my $here = $args{where} || [caller];
Condition50%1/2
$args{'where'} || [caller]
l!l
01
MC/DC0%0/1
$args{'where'} || [caller]
$args{'where'}
Truth table50%1/2
A
A= $args{'where'}
Aresult
11
00
46 1 ▶ if(my $s = $self->{LRMD_where})
Branch: 1 branch
BranchTrueFalseTotal
if (my $s = $self->{"LRMD_where"}) 0 1 1
47 0 { my $domain = $self->name;
48 0 die "only one package can contain configuration; for $domain already in $s->[0] in file $s->[1] line $s->[2]. Now also found at $here->[1] line $here->[2]\n";
49 }
50 1 my $where = $self->{LRMD_where} = $here;
51  
52 # documented in the super-class, the more useful man-page
53 1 ▶ my $format = $args{formatter} || 'PRINTI';
Condition50%1/2
$args{'formatter'} || 'PRINTI'
l!l
01
MC/DC0%0/1
$args{'formatter'} || 'PRINTI'
$args{'formatter'}
Truth table50%1/2
A
A= $args{'formatter'}
Aresult
11
00
54 1 ▶ $format = {} if $format eq 'PRINTI';
Branch: 1 branch
BranchTrueFalseTotal
if $format eq "PRINTI" 1 0 1
55  
56 1 ▶ if(ref $format eq 'HASH')
Branch: 2 branches
BranchTrueFalseTotal
if (ref $format eq 'HASH') { } 1 0 1
elsif (ref $format eq 'CODE') { } 0 0 0
57 1 ▶ { my $class = delete $format->{class} || 'String::Print';
Condition50%1/2
delete $format->{'class'} || 'String::Print'
l!l
01
MC/DC0%0/1
delete $format->{'class'} || 'String::Print'
delete $format->{'class'}
Truth table50%1/2
A
A= delete $format->{'class'}
Aresult
11
00
58 1 ▶ my $method = delete $format->{method} || 'sprinti';
Condition50%1/2
delete $format->{'method'} || 'sprinti'
l!l
01
MC/DC0%0/1
delete $format->{'method'} || 'sprinti'
delete $format->{'method'}
Truth table50%1/2
A
A= delete $format->{'method'}
Aresult
11
00
59 1 my $sp = $class->new(%$format);
60 1 ▶ $self->{LRMD_format} = sub { $sp->$method(@_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
61 }
62 elsif(ref $format eq 'CODE')
63 0 { $self->{LRMD_format} = $format;
64 }
65 else
66 0 { error __x"illegal formatter `{name}' at {fn} line {line}", name => $format, fn => $where->[1], line => $where->[2];
67 }
68  
69 1 $self;
70 }
71  
72 #--------------------
73  
74 sub interpolate(@)
75 3 ▶{ my ($self, $msgid, $args) = @_;
Subroutine interpolate: called CC=3 SCAR=11.3
Pod documented
76 3 ▶ $args->{_expand} or return $msgid;
Branch: 1 branch
BranchTrueFalseTotal
$args->{"_expand"} or return $msgid 3 0 3
77  
78 3 ▶ my $f = $self->{LRMD_format} || $self->configure->{LRMD_format};
Condition66%2/3
$self->{'LRMD_format'} || $self->configure->{'LRMD_format'}
l!l&&r!l&&!r
210
MC/DC0%0/2
$self->{'LRMD_format'} || $self->configure->{'LRMD_format'}
$self->{'LRMD_format'} $self->configure->{'LRMD_format'}
Truth table66%2/3
A || B
A= $self->{'LRMD_format'}B= $self->configure->{'LRMD_format'}
ABresult
1X1
011
000
79 3 $f->($msgid, $args);
80 }
81  
82 4 1;
« Minimal.pm ↑ Summary Optional.pm »