File Coverage

blib/lib/Text/Trac/LinkResolver/Log.pm
Criterion Covered Total %
statement 18 18 100.0
branch 3 4 75.0
condition 4 6 66.6
subroutine 5 5 100.0
pod 0 2 0.0
total 30 35 85.7


line stmt bran cond sub pod time code
1             package Text::Trac::LinkResolver::Log;
2              
3 8     8   56 use strict;
  8         17  
  8         230  
4 8     8   38 use warnings;
  8         16  
  8         213  
5 8     8   74 use base qw( Text::Trac::LinkResolver );
  8         15  
  8         45  
6              
7             our $VERSION = '0.23';
8              
9             sub init {
10 1607     1607 0 2412 my $self = shift;
11 1607         3342 $self->{pattern} = '!?\[\d+:\d+\]|(?:\b|!)r\d+:\d+\b';
12             }
13              
14             sub format_link {
15 8     8 0 28 my ( $self, $match, $target, $label ) = @_;
16 8 100       54 return $match if $self->_is_disabled;
17              
18 7         28 my $c = $self->{context};
19 7   66     36 $label ||= $match;
20 7         46 my ( $from, $to ) = ( $match =~ m/(\d+):(\d+)/ );
21              
22 7   66     154 my $url = $c->{trac_log_url} || $c->trac_url . 'log/';
23 7 50       132 return sprintf '%s', ( $c->{class} ? q{class="source"} : '' ), $url,
24             $to, $from, $label;
25             }
26              
27             1;