]> iEval git - app-lastmsg.git/blobdiff - lib/App/Lastmsg.pm
Bump version and update Changes
[app-lastmsg.git] / lib / App / Lastmsg.pm
index a5a27b59c42af9fea88cebcfee4c86d870469561..8f7be5ed663814c2b79960e88a2d5cf757965b05 100644 (file)
@@ -12,12 +12,14 @@ use List::Util qw/max/;
 use POSIX qw/strftime/;
 
 our $OUTPUT_FILEHANDLE = \*STDOUT;
-our $VERSION = '0.001002';
+our $VERSION = '0.002';
 
 our @DEFAULT_INBOX;
 push @DEFAULT_INBOX, "/var/mail/$ENV{USER}" if exists $ENV{USER};
 push @DEFAULT_INBOX, "$ENV{HOME}/Maildir"   if exists $ENV{HOME};
 
+sub format_time { strftime '%c', localtime shift }
+
 sub run {
        my $config = Config::Auto->new(format => 'yaml')->parse;
        die "No configuration file found\n" unless $config;
@@ -57,15 +59,14 @@ sub run {
 
        for my $folder (@{$config->{inbox}}) {
                next unless -e $folder;
-               say "Scanning $folder (inbox)" if $ENV{LASTMSG_DEBUG};
+               say STDERR "Scanning $folder (inbox)" if $ENV{LASTMSG_DEBUG};
                my $folder = Email::Folder->new($folder);
                while (my $msg = $folder->next_message) {
                        my ($from) = grep { /^from$/i } $msg->header_names;
                        $from = $msg->header_raw($from);
                        if ($ENV{LASTMSG_DEBUG}) {
-                               my $mid = grep { /^message-id$/i } $msg->header_names;
-                               say 'Processing ', $msg->header_raw('Message-ID'),
-                                 " from $from" if $ENV{LASTMSG_DEBUG};
+                               my ($mid) = grep { /^message-id$/i } $msg->header_names;
+                               say STDERR 'Processing ', $msg->header_raw($mid), " from $from";
                        }
                        $process_message->($msg, $from);
                }
@@ -73,7 +74,7 @@ sub run {
 
        for my $folder (@{$config->{sent}}) {
                next unless -e $folder;
-               say "Scanning $folder (sent)" if $ENV{LASTMSG_DEBUG};
+               say STDERR "Scanning $folder (sent)" if $ENV{LASTMSG_DEBUG};
                my $folder = Email::Folder->new($folder);
                while (my $msg = $folder->next_message) {
                        my @hdrs = grep { /^(?:to|cc|bcc)$/i } $msg->header_names;
@@ -82,9 +83,9 @@ sub run {
                                @people = (@people, split /,/, $msg->header_raw($hdr));
                        }
                        if ($ENV{LASTMSG_DEBUG}) {
-                               my $mid = grep { /^message-id$/i } $msg->header_names;
-                               say 'Processing ', $msg->header_raw($mid),
-                                 ' sent to ', join ',', @people if $ENV{LASTMSG_DEBUG};
+                               my ($mid) = grep { /^message-id$/i } $msg->header_names;
+                               say STDERR 'Processing ', $msg->header_raw($mid),
+                                 ' sent to ', join ',', @people;
                        }
                        $process_message->($msg, @people);
                }
@@ -94,7 +95,7 @@ sub run {
        my $addrlen = max map { length } values %lastaddr;
 
        for (sort { $lastmsg{$b} <=> $lastmsg{$a} } keys %lastmsg) {
-               my $time = strftime '%c', localtime $lastmsg{$_};
+               my $time = format_time $lastmsg{$_};
                printf $OUTPUT_FILEHANDLE "%-${idlen}s %-${addrlen}s %s\n", $_, $lastaddr{$_}, $time;
        }
 
@@ -132,7 +133,7 @@ Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2016 by Marius Gavrilescu
+Copyright (C) 2016-2017 by Marius Gavrilescu
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.24.1 or,
This page took 0.02391 seconds and 4 git commands to generate.