File Coverage

blib/lib/Text/Trac/LinkResolver/Ticket.pm
Criterion Covered Total %
statement 19 19 100.0
branch 3 4 75.0
condition 4 6 66.6
subroutine 5 5 100.0
pod 0 2 0.0
total 31 36 86.1


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