File Coverage

blib/lib/App/Slackeria/Plugin.pm
Criterion Covered Total %
statement 9 31 29.0
branch 0 6 0.0
condition 0 12 0.0
subroutine 3 5 60.0
pod 2 2 100.0
total 14 56 25.0


line stmt bran cond sub pod time code
1             package App::Slackeria::Plugin;
2              
3 14     14   729824 use strict;
  14         50  
  14         677  
4 14     14   103 use warnings;
  14         30  
  14         573  
5 14     14   626 use 5.010;
  14         59  
  14         16848  
6              
7             our $VERSION = '0.12';
8              
9             sub new {
10 0     0 1   my ( $obj, %conf ) = @_;
11 0           my $ref = {};
12 0           $ref->{default} = \%conf;
13 0           return bless( $ref, $obj );
14             }
15              
16             sub run {
17 0     0 1   my ( $self, $check_conf ) = @_;
18 0           my %conf = %{ $self->{default} };
  0            
19 0           my $ret;
20              
21 0           for my $key ( keys %{$check_conf} ) {
  0            
22 0           $conf{$key} = $check_conf->{$key};
23             }
24              
25 0 0 0       if ( ( defined $conf{enable} and $conf{enable} == 0 )
      0        
26             or $conf{disable} )
27             {
28             return {
29 0           data => q{},
30             skip => 1,
31             };
32             }
33              
34 0           $self->{conf} = \%conf;
35              
36 0           $ret = eval { $self->check() };
  0            
37              
38 0 0 0       if ( $@ or not defined $ret ) {
39             return {
40 0           ok => 0,
41             data => $@,
42             };
43             }
44              
45 0 0 0       if ( defined $conf{href} and not defined $ret->{href} ) {
46 0           $ret->{href} = sprintf( $conf{href}, $conf{name} );
47             }
48 0           $ret->{ok} = 1;
49 0           return $ret;
50             }
51              
52             1;
53              
54             __END__