Skip to content

Commit

Permalink
add -debug option
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitum committed Dec 3, 2011
1 parent 514b641 commit 205183b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion bin/metacpan_notify.pl
Expand Up @@ -3,8 +3,14 @@
use strict; use strict;
use warnings; use warnings;


my %params;
my $arg = shift;
if ( $arg && $arg eq '-debug' ) {
$params{debug} = 1;
}

use App::MetaCPAN::Gtk2::Notify; use App::MetaCPAN::Gtk2::Notify;
App::MetaCPAN::Gtk2::Notify->run(); App::MetaCPAN::Gtk2::Notify->run(%params);


=head1 NAME =head1 NAME
Expand Down
8 changes: 5 additions & 3 deletions lib/App/MetaCPAN/Gtk2/Notify.pm
Expand Up @@ -45,7 +45,11 @@ This starts notifier.
=cut =cut


my %prev_id;

sub run { sub run {
my ( $class, %params ) = @_;
$prev_id{1} = 1 if $params{debug};
while (1) { while (1) {
my @recent = get_recent(); my @recent = get_recent();
show_recent( \@recent ) if @recent; show_recent( \@recent ) if @recent;
Expand All @@ -72,8 +76,6 @@ sub get_recent {
} }
} }


my %prev_id;

=head2 show_recent(\@recent) =head2 show_recent(\@recent)
Show notifications about recent packages Show notifications about recent packages
Expand All @@ -84,7 +86,7 @@ sub show_recent {
my $recent = shift; my $recent = shift;


# skip notifying on first run # skip notifying on first run
if ( %prev_id ) { if (%prev_id) {
for ( reverse @$recent ) { for ( reverse @$recent ) {
next if $prev_id{ $_->{id} }; next if $prev_id{ $_->{id} };
my ( $auth_name, $avatar ) = @{ get_author( $_->{author} ) }; my ( $auth_name, $avatar ) = @{ get_author( $_->{author} ) };
Expand Down

0 comments on commit 205183b

Please sign in to comment.