blib/lib/Kwiki/ShortcutLinks.pm

filter: Statementstmt 62.0% 36 / 58 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 69.2% 9 / 13 Podpod 0.0% 0 / 1 totaltotal 55.5% 45 / 81 CC 5 SCAR 18.2
CC
5
Cov
55%
html
20.0
register
6.0
default_configs
2.0
CRAP 6.2
↑ Summary
1 package Kwiki::ShortcutLinks;
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 Kwiki::Installer '-base';
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 #use Kwiki::ShortcutLinks::Config;
8  
9 1 our $VERSION = 0.03;
10  
11 1 const class_title => 'Shortcut Links';
12 1 const class_id => 'shortcut_links';
13  
14 1 field shortcuts => undef;
15  
16 0 ▶sub register {
Subroutine register: not called CC=2 SCAR=17.9
Pod undocumented
17 0 my $registry = shift;
18  
19 0 my %config = Kwiki::ShortcutLinks::Config->new->all;
20
21 0 foreach my $key (keys %config) {
22 0 $registry->add(wafl => $key => 'Kwiki::ShortcutLinks::Wafl');
23 0 $registry->add(shortcut_links => $key => $config{$key});
24 }
25 }
26  
27 package Kwiki::ShortcutLinks::Wafl;
28 1 ▶use Spoon::Formatter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use base 'Spoon::Formatter::WaflPhrase';
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 0 ▶sub html {
Subroutine html: not called CC=4 SCAR=30.0
32 0 my $text = $self->arguments;
33 0 my $key = $self->method;
34 0 my $shortcut = $self->hub->registry->lookup->{shortcut_links}{$key}[1];
35  
36 0 my ($url_prefix, $link_prefix) = ($shortcut =~ /^(\S+)\s*(.*)?$/);
37 0 my ($url_param, $link_text) = ($text =~ /\A(.+?)(?:\|(.*))?\Z/);
38  
39 0 ▶ $link_text ||= ($link_prefix ? "$link_prefix " : '')
Branch: 1 branch
BranchTrueFalseTotal
$link_prefix ? : 0 0 0
Condition0%0/3
$link_text ||= ($link_prefix ? "$link_prefix " : "") . $self->html_escape($url_param)
l!l&&r!l&&!r
000
MC/DC0%0/2
$link_text ||= ($link_prefix ? "$link_prefix " : "") . $self->html_escape($url_param)
$link_text ($link_prefix ? "$link_prefix " : "") . $self->html_escape($url_param)
Truth table0%0/3
A ||= B
A= $link_textB= ($link_prefix ? "$link_prefix " : "") . $self->html_escape($url_param)
ABresult
1X1
011
000
40 . $self->html_escape($url_param);
41  
42 0 my $url = $url_prefix;
43 0 $url_param = $self->uri_escape($url_param);
44 0 ▶ $url .= "%s" unless ($url =~ /%s/);
Branch: 1 branch
BranchTrueFalseTotal
unless $url =~ /%s/ 0 0 0
45 0 $url =~ s/%s/$url_param/g;
46  
47 0 qq{<a href="$url">$link_text</a>};
48 }
49  
50 package Kwiki::ShortcutLinks::Config;
51 1 ▶use Spoon::Config '-Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 1 const class_title => 'Shortcut Links Configuration';
54 1 const class_id => 'shortcut_links_config';
55 1 const config_file => 'shortcuts.yaml';
56  
57 0 ▶sub default_configs { $self->config_file }
Subroutine default_configs: not called CC=1 SCAR=6.9
58 0 ▶sub default_config { return { }; }
Subroutine default_config: not called CC=1 SCAR=6.9
59  
60 package Kwiki::ShortcutLinks;
61  
62 1 1;
63  
64 1 __DATA__
↑ Summary