File Coverage

blib/lib/Text/Trac/LinkResolver/Comment.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 4 50.0
condition 2 6 33.3
subroutine 5 5 100.0
pod 0 2 0.0
total 29 37 78.3


line stmt bran cond sub pod time code
1             package Text::Trac::LinkResolver::Comment;
2              
3 8     8   55 use strict;
  8         16  
  8         223  
4 8     8   38 use warnings;
  8         17  
  8         203  
5 8     8   39 use base qw( Text::Trac::LinkResolver );
  8         16  
  8         39  
6              
7             our $VERSION = '0.22';
8              
9             sub init {
10 1607     1607 0 2405 my $self = shift;
11 1607         3471 $self->{pattern} = '!?(?
12             }
13              
14             sub format_link {
15 1     1 0 4 my ( $self, $match, $target, $label ) = @_;
16 1 50       9 return $match if $self->_is_disabled;
17              
18 1         6 my $c = $self->{context};
19 1   33     7 $label ||= $match;
20 1         7 my ( $rev, $commentId ) = ( $match =~ m/(\d+):(\d+)/ );
21              
22 1   33     27 my $url = $c->{trac_ticket_url} || $c->trac_url . 'ticket/';
23 1         11 $url .= $rev;
24 1         3 $url .= "#comment:$commentId";
25 1 50       14 return sprintf '%s', ( $c->{class} ? q{class="ticket"} : '' ), $url, $label;
26             }
27              
28             1;