blib/lib/CPAN/Mini/Growl.pm

filter: Statementstmt 88.2% 15 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.3% 21 / 23 CC 1 SCAR 0.5
CC
1
Cov
88%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package CPAN::Mini::Growl;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use 5.008_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 our $VERSION = '0.03';
6  
7 1 ▶use base qw( CPAN::Mini );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Digest::MD5;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 0 ▶use Mac::Growl;
Subroutine BEGIN: called CC=1 SCAR=2.6
11 use LWP::Simple;
12 use CPAN::DistnameInfo;
13 use Parse::CPAN::Authors;
14  
15 my $AppName = "CPAN::Mini::Growl";
16 my $EventType = "New Distribution";
17  
18 sub update_mirror {
19 my $class = shift;
20 my $self = $class->SUPER::new(@_);
21 $self->SUPER::update_mirror;
22  
23 Mac::Growl::RegisterNotifications($AppName, [ $EventType ], [ $EventType ]);
24  
25 my $file = File::Spec->catfile($self->{local}, "authors", "01mailrc.txt.gz");
26 my $pause = Parse::CPAN::Authors->new($file);
27  
28 my $cache = File::Spec->catfile($self->{local}, "avatars");
29 mkdir $cache, 0777 unless -e $cache;
30  
31 my @modules = grep !/CHECKSUMS/, keys %{$self->{recent}};
32 for my $module (@modules) {
33 if ($module =~ m!^authors/id/!) {
34 my $dist = CPAN::DistnameInfo->new($module) or next;
35 my $author = $pause->author($dist->cpanid) or next;
36 my $icon = File::Spec->catfile($cache, $dist->cpanid . ".jpg");
37 unless (-e $icon) {
38 my $md5 = Digest::MD5::md5_hex($author->email);
39 my $gravatar = "http://www.gravatar.com/avatar.php?gravatar_id=$md5&rating=G&size=80&default=http%3A%2F%2Fst.pimg.net%2Ftucs%2Fimg%2Fwho.png";
40 LWP::Simple::mirror($gravatar, $icon);
41 }
42  
43 my $msg = $author->name . " released " . $dist->distvname;
44 Mac::Growl::PostNotification($AppName, $EventType, $dist->distvname, $msg, 0, 0, $icon);
45 }
46 }
47 }
48  
49 1;
50 __END__
↑ Summary