Wiki/Plugin/Inline/URL.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 35 / 35 CC 3 SCAR 4.1
CC
3
Cov
100%
process
2.0
_cut
2.0
BEGIN
1.0
CRAP 1.5
« Wiki/Plugin/Block/DL.pm ↑ Summary Wiki/Plugin/Inline/Footnote.pm »
1 package Text::Livedoor::Wiki::Plugin::Inline::URL;
2  
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use base qw(Text::Livedoor::Wiki::Plugin::Inline);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use Text::Livedoor::Wiki::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 __PACKAGE__->regex( q{((?:http|https|ftp):\/\/[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+)});
9 10 __PACKAGE__->n_args(2);
10  
11 12 ▶sub process {
Subroutine process: called CC=2 SCAR=6.9
Pod documented
12 12 my ( $class, $inline, $url ) = @_;
13 12 ▶ return qq|<a href="$url"><img src="$url" border="0"/></a>| if Text::Livedoor::Wiki::Utils::is_image_url( $url );
Branch: 1 branch
BranchTrueFalseTotal
if Text::Livedoor::Wiki::Utils::is_image_url($url) 1 11 12
14 11 my $label = $class->_cut( $url );
15 11 return qq{<a href="$url" class=\"outlink\">$label</a>};
16  
17 }
18  
19 11 ▶sub _cut {
Subroutine _cut: called CC=2 SCAR=6.9
20 11 my $class= shift;
21 11 my $url = shift;
22 11 ▶ if ( length $url > 50 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $url > 50) 2 9 11
23 2 return substr($url , 0 , 50 ) . '...';
24 }
25 9 return $url;
26 }
27  
28 10 1;
29  
30 =head1 NAME
31  
32 Text::Livedoor::Wiki::Plugin::Inline::URL - URL Inline Plugin
33  
34 =head1 DESCRIPTION
35  
36 make URL linkable.
37  
38 =head1 SYNOPSIS
39  
40 http://wiki.livedoor.com
41  
42 =head1 FUNCTION
43  
44 =head2 process
45  
46 =head1 AUTHOR
47  
48 polocky
49  
50 =cut
« Wiki/Plugin/Block/DL.pm ↑ Summary Wiki/Plugin/Inline/Footnote.pm »