File Coverage

blib/lib/Log/Dispatch/DesktopNotification.pm
Criterion Covered Total %
statement 22 27 81.4
branch 2 6 33.3
condition 1 3 33.3
subroutine 7 7 100.0
pod 2 2 100.0
total 34 45 75.5


line stmt bran cond sub pod time code
1 1     1   17699 use strict;
  1         2  
  1         37  
2 1     1   4 use warnings;
  1         1  
  1         54  
3             package Log::Dispatch::DesktopNotification; # git description: v0.01-6-g47bff86
4             # ABSTRACT: Send log messages to a desktop notification system
5             $Log::Dispatch::DesktopNotification::VERSION = '0.02';
6 1     1   21904 use Module::Load qw/load/;
  1         986  
  1         6  
7 1     1   2153 use Module::Load::Conditional qw/can_load/;
  1         22722  
  1         62  
8 1     1   488 use namespace::clean;
  1         17372  
  1         6  
9              
10             #pod =head1 SYNOPSIS
11             #pod
12             #pod my $notify = Log::Dispatch::DesktopNotification->new(
13             #pod name => 'notify',
14             #pod min_level => 'debug',
15             #pod app_name => 'MyApp',
16             #pod );
17             #pod
18             #pod =head1 METHODS
19             #pod
20             #pod =head2 new
21             #pod
22             #pod Creates a new L output that can be used to graphically notify a
23             #pod user on this system. Uses C and calls C on the returned
24             #pod class, passing along all arguments.
25             #pod
26             #pod =cut
27              
28             sub new {
29 1     1 1 14 my ($class, @args) = @_;
30 1         5 return $class->output_class->new(@args);
31             }
32              
33             #pod =head2 output_class
34             #pod
35             #pod Returns the name of a L class that is suitable to
36             #pod graphically notify a user on the current system.
37             #pod
38             #pod On MacOS X, that will be L. On other systems,
39             #pod L will be returned if it is available and usable.
40             #pod Otherwise, L will be returned.
41             #pod
42             #pod =cut
43              
44             sub output_class {
45 1 50   1 1 5 if ($^O eq 'darwin') {
46 0         0 my $mod = 'Log::Dispatch::MacGrowl';
47 0         0 load $mod; return $mod;
  0         0  
48             }
49              
50 1 50 33     6 if (can_load(modules => { Gtk2 => undef }) && Gtk2->init_check) {
51 0         0 my $mod = 'Log::Dispatch::Gtk2::Notify';
52 0 0       0 return $mod if can_load(modules => { $mod => undef });
53             }
54              
55 1         466 my $mod = 'Log::Dispatch::Null';
56 1         5 load $mod; return $mod;
  1         8079  
57             }
58              
59             #pod =head1 BUGS
60             #pod
61             #pod Currently only supports Mac OS X and systems on which notification-daemon is
62             #pod available (most *N*Xes).
63             #pod
64             #pod =head1 SEE ALSO
65             #pod
66             #pod =for :list
67             #pod * L
68             #pod * L
69             #pod * L
70             #pod * L
71             #pod
72             #pod =cut
73              
74             1;
75              
76             __END__