| 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
Condition66%2/3
ref $self and eval {
do {
$self->isa(__PACKAGE__)
}
}
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__)
}
}
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 104 | ▶ | $text = '' unless defined $text; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 ||= {}
MC/DC0%0/1
$base ||= {}
$base
Truth table50%1/2
A
A= $base
| |||||||||||||||||||||||||||||
| 38 | 104 | ▶ | $overrides ||= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$overrides ||= {}
MC/DC100%1/1
$overrides ||= {}
$overrides
Truth table100%2/2
A
A= $overrides
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 104 | my %merged = (%{$base}, %{$overrides}); | |||||||||||||||||||||||||||
| 41 | 104 | ▶ | if (ref($base->{attributes}) eq 'HASH' || ref($overrides->{attributes}) eq 'HASH') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $base->{"attributes"} eq "HASH" or ref $overrides->{"attributes"} eq "HASH"
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"
| |||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||
| 43 | my %attrs = ( | ||||||||||||||||||||||||||||
| 44 | 7 | ▶ | %{ref($base->{attributes}) eq 'HASH' ? $base->{attributes} : {}}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 7 | ▶ | %{ref($overrides->{attributes}) eq 'HASH' ? $overrides->{attributes} : {}}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | 7 | $merged{attributes} = \%attrs; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 104 | return \%merged; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 18 | 1; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||