lib/Kwiki/CoolURI.pm

filter: Statementstmt 52.0% 25 / 48 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.6% 7 / 11 Podpod 33.3% 1 / 3 totaltotal 48.5% 33 / 68 CC 4 SCAR 14.4
CC
4
Cov
46%
uri_hook
12.0
html
6.0
init
2.0
CRAP 4.2
↑ Summary
1 package Kwiki::CoolURI;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Kwiki::Plugin -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use mixin 'Kwiki::Installer';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.04';
8  
9 1 const class_id => 'cool_uri';
10 1 const class_title => "Cool URIs don't change";
11  
12 0 ▶sub init {
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
13 0 super;
14 0 $self->hub->template->add_path('plugin/cool_uri/template/tt2');
15 0 my $formatter = $self->hub->load_class('formatter');
16 0 $formatter->table->{forced} = 'Kwiki::CoolURI::ForcedLink';
17 }
18  
19 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
20 0 my $registry = shift;
21 0 $registry->add(preload => 'cool_uri');
22 0 $registry->add(hook => 'page:kwiki_link', pre => 'uri_hook');
23 }
24  
25 0 ▶sub uri_hook {
Subroutine uri_hook: not called CC=3 SCAR=24.8
Pod undocumented
26 0 my $hook = pop;
27 0 $hook->code(undef);
28 0 my ($label) = @_;
29 0 my $page_uri = $self->uri;
30 0 ▶ $label = $self->title
Branch: 1 branch
BranchTrueFalseTotal
unless defined $label 0 0 0
31 unless defined $label;
32 0 ▶ my $class = $self->active
Branch: 1 branch
BranchTrueFalseTotal
$self->active ? : 0 0 0
33 ? '' : ' class="empty"';
34 0 qq(<a href="$page_uri"$class>$label</a>);
35 }
36  
37 package Kwiki::CoolURI::ForcedLink;
38 1 ▶use base 'Kwiki::Formatter::ForcedLink';
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 0 ▶sub html {
Subroutine html: not called CC=2 SCAR=17.9
41 0 $self->matched =~ $self->pattern_start;
42 0 my $target = $1;
43 0 my $text = $self->escape_html($target);
44 0 ▶ my $class = $self->hub->pages->new_from_name($target)->exists
Branch: 1 branch
BranchTrueFalseTotal
$self->hub->pages->new_from_name($target)->exists ? : 0 0 0
45 ? '' : ' class="empty"';
46 0 return qq(<a href="$target"$class>$target</a>);
47 }
48  
49 package Kwiki::CoolURI;
50 1 __DATA__
↑ Summary