File Coverage

blib/lib/SVK/Log/Filter/Mndrix.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package SVK::Log::Filter::Mndrix;
2              
3 1     1   39122 use warnings;
  1         3  
  1         35  
4 1     1   7 use strict;
  1         2  
  1         40  
5              
6 1     1   6 use base qw( SVK::Log::Filter::Output );
  1         1  
  1         993  
7             use Perl6::Form;
8             use Text::Autoformat;
9             use Time::Local qw( timegm );
10             use POSIX qw( strftime );
11             use Term::ReadKey;
12              
13             our $VERSION = '0.0.3';
14              
15             sub revision {
16             my ($self, $args) = @_;
17             my $props = $args->{props};
18             my $rev = $args->{rev};
19             my $stash = $args->{stash};
20              
21             my $author = $props->{'svn:author'} || '(none)';
22             my $message = $props->{'svn:log'};
23             $message = q{} if !defined $message;
24             my $columns = $stash->{quiet}
25             ? $ENV{COLUMNS} || (GetTerminalSize())[0] || 80
26             : 80
27             ;
28              
29             # clean up messages with SVK lump headers
30             if ( $message =~ s{\A \s* r\d+ [@] .*? $ \s* }{}xms ) {
31             $message =~ s/^ \s //xmsg;
32             }
33             my ($first, $rest) = split /\n\n+/, $message, 2;
34             $message = autoformat(
35             $first || q{},
36             {
37             left => 0,
38             right => $columns - 28,
39             }
40             );
41             $message .= $rest if $stash->{verbose} and $rest;
42              
43             my ($day, $date, $time) = date_and_time(
44             $props->{'svn:date'},
45             $stash->{quiet} ? '-' : ' ',
46             );
47              
48             # determine the formats for the log message
49             my $quiet_format = '{' . q{'}x($columns-28) . '}';
50              
51             # handle the quiet form
52             print form
53             # r author date log message
54             "{<<<} {<<<<<<} {<<<<<<<<<} $quiet_format",
55             $rev, $author,$date, $message
56             if $stash->{quiet};
57             return if $stash->{quiet};
58              
59             # handle the other form
60             my $get_remote_rev = $args->{get_remoterev} || sub {};
61             my $remote_rev = $get_remote_rev->($rev) || 'no';
62             $message = ' ' if !defined($message) or !length($message);
63             print form
64             '-----------------------------[ Revision : {>>>>} ]-----------------------------',
65             $rev,
66             'Author: {<<<<<<} Log:',
67             $author,
68             "Day : {<<<<<<<} {''''''''''''''''''''''''''''''''''''''''''''''''''''''''}",
69             $day, $message,
70             'Date : {<<<<<<<<<} {VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV}',
71             $date,
72             'Time : {<<<<<<} {VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV}',
73             $time,
74             'Remote: {<<<<} {VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV}',
75             $remote_rev,
76             ' {VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV}',
77             ;
78              
79             }
80              
81             sub date_and_time {
82             my ($raw, $s) = @_;
83              
84             my (
85             $year,
86             $month,
87             $d,
88             $hour,
89             $minute,
90             $second,
91             $nanos
92             ) = split /[-T:.]/, $raw;
93             $year -= 1900;
94             $month--;
95              
96             my $t = timegm($second, $minute, $hour, $d, $month, $year);
97             my $day = strftime('%A', localtime($t) );
98             my $time = strftime('%T', localtime($t) );
99             my $date = strftime("\%e$s\%b$s\%Y", localtime($t) );
100              
101             return ($day, $date, $time);
102             }
103              
104             1;
105              
106             __END__