| 1 | package Jaipo::Notify; | ||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use base qw/Class::Accessor::Fast/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 2 | __PACKAGE__->mk_accessors (qw/notifier/); | |||||||||||||
| 6 | |||||||||||||||
| 7 | sub new { | ||||||||||||||
| 8 | 1 | ▶ | my $class = shift; | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 9 | 1 | my $arg = shift; # should be "1" or the module name "Jaipo::Notify::SomeNotify::Module" | |||||||||||||
| 10 | 1 | my $self = {}; | |||||||||||||
| 11 | 1 | bless $self , $class; | |||||||||||||
| 12 | 1 | $self->init($arg); | |||||||||||||
| 13 | 0 | return $self; | |||||||||||||
| 14 | } | ||||||||||||||
| 15 | |||||||||||||||
| 16 | sub init { | ||||||||||||||
| 17 | 1 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
init: called CC=4 SCAR=16.3
Pod
undocumented
| |||||||||||||||
| 18 | 1 | my $notify_module = shift; | |||||||||||||
| 19 | 1 | $self->notifier( {} ); | |||||||||||||
| 20 | |||||||||||||||
| 21 | 1 | ▶ | if ( not $notify_module ) { # use default notify module | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 22 | 1 | ▶ | if( $^O =~ m/linux/i ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 23 | 1 | $notify_module = "Jaipo::Notify::LibNotify"; | |||||||||||||
| 24 | } elsif ( $^O =~ m/darwin/i ) { | ||||||||||||||
| 25 | 0 | $notify_module = "Jaipo::Notify::MacGrwol"; | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | } | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 1 | eval "require $notify_module"; | |||||||||||||
| 30 | 1 | my $notify = $notify_module->new; | |||||||||||||
| 31 | |||||||||||||||
| 32 | # save notify object to accessor | ||||||||||||||
| 33 | 0 | $self->notifier( $notify ); | |||||||||||||
| 34 | 0 | print "$notify_module Notifier Initialized\n"; | |||||||||||||
| 35 | } | ||||||||||||||
| 36 | |||||||||||||||
| 37 | sub create { | ||||||||||||||
| 38 | 0 | ▶ | my ( $self, $args ) = @_; | ||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 39 | 0 | $self->notifier->yell( $args->{message} ); | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 2 | 1; | |||||||||||||