lib/Text/AsciidocDown.pm

filter: Statementstmt 100% 41 / 41 Branchbran 80.0% 8 / 10 Conditioncond 70.0% 7 / 10 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 89.7% 70 / 78 CC 10 SCAR 14.0
CC
10
Cov
92%
_merge_options
7.1
convert
4.0
BEGIN
1.0
CRAP 4.0
« lib/Text/AsciidocDown/Subs.pm ↑ Summary /usr/local/bin/perldoc »
1 package Text::AsciidocDown;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 18 ▶use version 0.77;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 18 our $VERSION = '0.1.3';
9  
10 18 ▶use Text::AsciidocDown::Include ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 18 ▶use Text::AsciidocDown::Parser ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new
14 88 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
15 88 my ($class, %opts) = @_;
16 88 return bless {options => \%opts}, $class;
17 }
18  
19 sub convert
20 105 ▶{
Subroutine convert: called CC=4 SCAR=14.0
Pod documented
21 105 my ($self, $text, $opts) = @_;
22  
23 croak 'convert must be called on an object instance (call ->new first)'
24 105 ▶ unless ref($self) && eval { $self->isa(__PACKAGE__) };
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self and eval { do { $self->isa(__PACKAGE__) } } 1 104 105
Condition66%2/3
ref $self and eval { do { $self->isa(__PACKAGE__) } }
!ll&&!rl&&r
10104
MC/DC50%1/2
ref $self and eval { do { $self->isa(__PACKAGE__) } }
ref $self eval { do { $self->isa(__PACKAGE__) } }
Truth table66%2/3
A and B
A= ref $selfB= eval { do { $self->isa(__PACKAGE__) } }
ABresult
0X0
100
111
25  
26 104 ▶ $text = '' unless defined $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text 0 104 104
27 104 $opts = _merge_options($self->{options}, $opts);
28  
29 104 $text = Text::AsciidocDown::Include::expand_includes($text, $opts);
30  
31 99 return Text::AsciidocDown::Parser::convert($text, $opts);
32 }
33  
34 sub _merge_options
35 104 ▶{
Subroutine _merge_options: called CC=7 SCAR=19.6
36 104 my ($base, $overrides) = @_;
37 104 ▶ $base ||= {};
Condition50%1/2
$base ||= {}
l!l
1040
MC/DC0%0/1
$base ||= {}
$base
Truth table50%1/2
A
A= $base
Aresult
11
00
38 104 ▶ $overrides ||= {};
Condition100%2/2
$overrides ||= {}
l!l
1022
MC/DC100%1/1
$overrides ||= {}
$overrides
Truth table100%2/2
A
A= $overrides
Aresult
11
00
39  
40 104 my %merged = (%{$base}, %{$overrides});
41 104 ▶ if (ref($base->{attributes}) eq 'HASH' || ref($overrides->{attributes}) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $base->{"attributes"} eq "HASH" or ref $overrides->{"attributes"} eq "HASH") 7 97 104
Condition66%2/3
ref $base->{"attributes"} eq "HASH" or ref $overrides->{"attributes"} eq "HASH"
l!l&&r!l&&!r
7097
MC/DC50%1/2
ref $base->{"attributes"} eq "HASH" or ref $overrides->{"attributes"} eq "HASH"
ref $base->{"attributes"} eq "HASH" ref $overrides->{"attributes"} eq "HASH"
Truth table66%2/3
A or B
A= ref $base->{"attributes"} eq "HASH"B= ref $overrides->{"attributes"} eq "HASH"
ABresult
1X1
011
000
42 {
43 my %attrs = (
44 7 ▶ %{ref($base->{attributes}) eq 'HASH' ? $base->{attributes} : {}},
Branch: 1 branch
BranchTrueFalseTotal
ref $base->{'attributes'} eq 'HASH' ? : 7 0 7
45 7 ▶ %{ref($overrides->{attributes}) eq 'HASH' ? $overrides->{attributes} : {}},
Branch: 1 branch
BranchTrueFalseTotal
ref $overrides->{'attributes'} eq 'HASH' ? : 5 2 7
46 );
47 7 $merged{attributes} = \%attrs;
48 }
49  
50 104 return \%merged;
51 }
52  
53 18 1;
54  
55 __END__
« lib/Text/AsciidocDown/Subs.pm ↑ Summary /usr/local/bin/perldoc »