| 1 | package Text::Markup::Any; | ||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 3 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Class::Load qw/load_class/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 3 | our @EXPORT = qw/markupper/; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 3 | my $markdown = {markup_method => 'markdown'}; | |||||||||||||||||||||||||||||||
| 13 | our %MODULES = ( | ||||||||||||||||||||||||||||||||
| 14 | 'Text::Markdown' => $markdown, | ||||||||||||||||||||||||||||||||
| 15 | 'Text::MultiMarkdown' => $markdown, | ||||||||||||||||||||||||||||||||
| 16 | 'Text::Markdown::Discount' => $markdown, | ||||||||||||||||||||||||||||||||
| 17 | 'Text::Markdown::GitHubAPI' => $markdown, | ||||||||||||||||||||||||||||||||
| 18 | 'Text::Markdown::Hoedown' => { | ||||||||||||||||||||||||||||||||
| 19 | class => 'Text::Markdown::Hoedown::Markdown', | ||||||||||||||||||||||||||||||||
| 20 | markup_method => 'render', | ||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | args => sub { [0, 16, Text::Markdown::Hoedown::Renderer::HTML->new(0, 99)] }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 3 | deref => 1, | |||||||||||||||||||||||||||||||
| 23 | }, | ||||||||||||||||||||||||||||||||
| 24 | 'Text::Xatena' => {markup_method => 'format'}, | ||||||||||||||||||||||||||||||||
| 25 | 'Text::Textile' => {markup_method => 'process'}, | ||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=29.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 29 | 4 | my ($pkg, $class, @args) = @_; | |||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 4 | my $args; | |||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $args = ref $args[0] ? $args[0] : {@args}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | my $info = $MODULES{$class} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 37 | or die "no configuration found: $class. You want to use $class, directory call $pkg->adaptor constractor."; | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | if ($args) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if ($info->{args} && ref($info->{args}) eq 'HASH') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info->{"args"} and ref $info->{"args"} eq "HASH"
MC/DC0%0/2
$info->{"args"} and ref $info->{"args"} eq "HASH"
$info->{"args"}
ref $info->{"args"} eq "HASH"
Truth table0%0/3
A and B
A= $info->{"args"}B= ref $info->{"args"} eq "HASH"
| |||||||||||||||||||||||||||||||||
| 41 | $info->{args} = { | ||||||||||||||||||||||||||||||||
| 42 | 0 | %{ $info->{args} }, | |||||||||||||||||||||||||||||||
| 43 | %$args, | ||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||||||||||||||
| 47 | 0 | $info->{args} = $args; | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 4 | ▶ | load_class($class) if $info->{class}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 4 | $pkg->adaptor( | |||||||||||||||||||||||||||||||
| 53 | class => $class, | ||||||||||||||||||||||||||||||||
| 54 | %$info, | ||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | # taken from Ark::Models | ||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | sub adaptor { | ||||||||||||||||||||||||||||||
|
Subroutine
adaptor: called CC=10 SCAR=25.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 60 | 4 | my ($pkg, %info) = @_; | |||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | my $class = $info{class} or die q{Required class parameter}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | my $markup_method = $info{markup_method} or die q{Required markup_method parameter}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | my $constructor = $info{constructor} || 'new'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$info{'constructor'} || 'new'
MC/DC0%0/1
$info{'constructor'} || 'new'
$info{'constructor'}
Truth table50%1/2
A
A= $info{'constructor'}
| |||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | 4 | load_class($class); | |||||||||||||||||||||||||||||||
| 67 | 4 | ▶ | $info{args} = $info{args}->() if ref $info{args} eq 'CODE'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 4 | my $instance; | |||||||||||||||||||||||||||||||
| 70 | 4 | ▶ | if ($info{deref} and my $args = $info{args}) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$info{"deref"} and my $args = $info{"args"}
MC/DC50%1/2
$info{"deref"} and my $args = $info{"args"}
$info{"deref"}
my $args = $info{"args"}
Truth table66%2/3
A and B
A= $info{"deref"}B= my $args = $info{"args"}
| |||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | if (ref($args) eq 'HASH') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 72 | 0 | $instance = $class->$constructor(%$args); | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | elsif (ref($args) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
| 75 | 1 | $instance = $class->$constructor(@$args); | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||||||
| 78 | 0 | die qq{Couldn't dereference: $args}; | |||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | elsif ($info{args}) { | ||||||||||||||||||||||||||||||||
| 82 | 0 | $instance = $class->$constructor($info{args}); | |||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | else { | ||||||||||||||||||||||||||||||||
| 85 | 3 | $instance = $class->$constructor; | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 4 | bless { | |||||||||||||||||||||||||||||||
| 89 | _instance => $instance, | ||||||||||||||||||||||||||||||||
| 90 | _markup_method => $markup_method, | ||||||||||||||||||||||||||||||||
| 91 | }, $pkg; | ||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 4 | ▶ | sub markup { | ||||||||||||||||||||||||||||||
|
Subroutine
markup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 95 | 4 | my ($self, @text) = @_; | |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 4 | my $meth = $self->{_markup_method}; | |||||||||||||||||||||||||||||||
| 98 | 4 | $self->{_instance}->$meth(@text); | |||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | sub markupper { | ||||||||||||||||||||||||||||||
|
Subroutine
markupper: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 102 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | $class = "Text::$class" unless $class =~ /^\+/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | 1 | __PACKAGE__->new($class, @_); | |||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 3 | 1; | |||||||||||||||||||||||||||||||
| 110 | __END__ | ||||||||||||||||||||||||||||||||