File Coverage

blib/lib/Log/Dispatch/FogBugz.pm
Criterion Covered Total %
statement 18 43 41.8
branch 0 10 0.0
condition 0 11 0.0
subroutine 6 9 66.6
pod 2 2 100.0
total 26 75 34.6


line stmt bran cond sub pod time code
1             package Log::Dispatch::FogBugz;
2              
3 1     1   38282 use warnings;
  1         3  
  1         33  
4 1     1   7 use strict;
  1         3  
  1         37  
5 1     1   981 use Log::Dispatch::Output;
  1         92978  
  1         38  
6 1     1   15 use base qw/Log::Dispatch::Output/;
  1         2  
  1         88  
7 1     1   6 use Carp qw{croak};
  1         2  
  1         59  
8              
9 1     1   173370 use LWP::UserAgent;
  1         134964  
  1         539  
10              
11             our $VERSION = '0.1';
12              
13             sub new {
14 0     0 1   my $proto = shift;
15 0   0       my $class = ref $proto || $proto;
16              
17 0           my %p = @_;
18              
19 0           my $self = bless {}, $class;
20              
21 0           $self->_basic_init(%p);
22 0           $self->_init(%p);
23 0           return $self;
24             }
25              
26             sub log_message {
27 0     0 1   my $self = shift;
28 0           my %p = @_;
29              
30 0 0         $self->{form}{Description} = $self->{params}{DescriptionPrefix} ? $self->{params}{DescriptionPrefix} : '';
31 0           $p{message} =~ $self->{params}{DescriptionRegex};
32              
33 0 0         if ( $1 ) {
34 0           $self->{form}{Description} .= $1;
35             }
36              
37 0           $self->{form}{Extra} = $p{message};
38              
39 0           my $ua = LWP::UserAgent->new;
40 0           my $resp = $ua->post($self->{params}{URL}, $self->{form});
41             }
42              
43             sub _init {
44 0     0     my ( $self, %opts ) = @_;
45 0           $self->{params} = \%opts;
46              
47 0           foreach my $req ( qw/URL Project User Area/ ) {
48 0 0         croak "Required configuration parameter `$req` was not defined" unless defined $opts{$req};
49             }
50              
51 0 0 0       unless ( $opts{DescriptionPrefix} or $opts{DescriptionRegex} ) {
52 0           croak "One of DescriptionPrefix or DescriptionRegex options are required";
53             }
54              
55 0 0 0       if ( $opts{DescriptionRegex} and ref($opts{DescriptionRegex}) ne 'Regexp' ) {
56 0           croak "DescriptionRegex must be a compiled regex (use qr{})";
57             }
58              
59 0   0       $self->{form} = {
60             ScoutProject => $opts{Project}
61             , ScoutUserName => $opts{User}
62             , ScoutArea => $opts{Area}
63             , ForceNewBug => ( $opts{ForceNewBug} || 0 )
64             , FriendlyResponse => 0
65             };
66             }
67              
68             __END__