[smolder-commits] SF.net SVN: smolder: [779] trunk
Brought to you by:
michael_peters
From: <mic...@us...> - 2008-06-16 18:59:39
|
Revision: 779 http://smolder.svn.sourceforge.net/smolder/?rev=779&view=rev Author: michael_peters Date: 2008-06-16 11:59:30 -0700 (Mon, 16 Jun 2008) Log Message: ----------- adding time_format filter for the durations of test runs Modified Paths: -------------- trunk/lib/Smolder/Control.pm trunk/lib/Smolder/Email.pm trunk/lib/Smolder/TAPHTMLMatrix.pm trunk/lib/Smolder/Util.pm trunk/templates/Developer/Projects/smoke_report_details.tmpl trunk/templates/TAP/full_report.tmpl Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Name: svk:merge - 6cb60ec2-19fc-4f48-ba02-516b4c84136d:/local/smolder:23500 ef85ff6a-427b-4ddd-bce6-61dc0fed61e7:/local/smolder/trunk:51024 + 6cb60ec2-19fc-4f48-ba02-516b4c84136d:/local/smolder:23500 ef85ff6a-427b-4ddd-bce6-61dc0fed61e7:/local/smolder/trunk:51026 Modified: trunk/lib/Smolder/Control.pm =================================================================== --- trunk/lib/Smolder/Control.pm 2008-06-16 15:53:46 UTC (rev 778) +++ trunk/lib/Smolder/Control.pm 2008-06-16 18:59:30 UTC (rev 779) @@ -270,12 +270,15 @@ # configuration options for CAP::TT (Template Toolkit) my $TT_CONFIG = { TEMPLATE_OPTIONS => { - COMPILE_DIR => catdir( InstallRoot, 'tmp' ), - INCLUDE_PATH => catdir( InstallRoot, 'templates' ), + COMPILE_DIR => catdir(InstallRoot, 'tmp'), + INCLUDE_PATH => catdir(InstallRoot, 'templates'), COMPILE_EXT => '.ttc', WRAPPER => 'wrapper.tmpl', RECURSION => 1, - FILTERS => { pass_fail_color => \&Smolder::Util::pass_fail_color }, + FILTERS => { + pass_fail_color => \&Smolder::Util::pass_fail_color, + format_time => \&Smolder::Util::format_time, + }, }, TEMPLATE_NAME_GENERATOR => sub { my $self = shift; @@ -283,19 +286,20 @@ # the directory is based on the object's package name my $mod = ref $self; $mod =~ s/Smolder::Control:://; - my $dir = catdir( split( /::/, $mod ) ); + my $dir = catdir(split(/::/, $mod)); # the filename is the method name of the caller - ( caller(2) )[3] =~ /([^:]+)$/; + (caller(2))[3] =~ /([^:]+)$/; my $name = $1; - if ( $name eq 'tt_process' ) { + if ($name eq 'tt_process') { # we were called from tt_process, so go back once more on the caller stack - ( caller(3) )[3] =~ /([^:]+)$/; + (caller(3))[3] =~ /([^:]+)$/; $name = $1; } - return catfile( $dir, $name . '.tmpl' ); + return catfile($dir, $name . '.tmpl'); }, + #TEMPLATE_PRECOMPILE_DIR => catdir( InstallRoot, 'templates'), }; __PACKAGE__->tt_config($TT_CONFIG); Modified: trunk/lib/Smolder/Email.pm =================================================================== --- trunk/lib/Smolder/Email.pm 2008-06-16 15:53:46 UTC (rev 778) +++ trunk/lib/Smolder/Email.pm 2008-06-16 18:59:30 UTC (rev 779) @@ -25,7 +25,10 @@ INCLUDE_PATH => catdir( InstallRoot, 'templates' ), COMPILE_EXT => '.ttc', WRAPPER => 'Email/wrapper.tmpl', - FILTERS => { pass_fail_color => \&Smolder::Util::pass_fail_color, }, + FILTERS => { + pass_fail_color => \&Smolder::Util::pass_fail_color, + format_time => \&Smolder::Util::format_time, + }, ); =head1 METHODS Modified: trunk/lib/Smolder/TAPHTMLMatrix.pm =================================================================== --- trunk/lib/Smolder/TAPHTMLMatrix.pm 2008-06-16 15:53:46 UTC (rev 778) +++ trunk/lib/Smolder/TAPHTMLMatrix.pm 2008-06-16 18:59:30 UTC (rev 779) @@ -15,7 +15,10 @@ COMPILE_DIR => catdir( InstallRoot, 'tmp' ), COMPILE_EXT => '.ttc', INCLUDE_PATH => catdir( InstallRoot, 'templates' ), - FILTERS => { pass_fail_color => \&Smolder::Util::pass_fail_color }, + FILTERS => { + pass_fail_color => \&Smolder::Util::pass_fail_color, + format_time => \&Smolder::Util::format_time, + }, ); # use Smolder::Control's version Modified: trunk/lib/Smolder/Util.pm =================================================================== --- trunk/lib/Smolder/Util.pm 2008-06-16 15:53:46 UTC (rev 778) +++ trunk/lib/Smolder/Util.pm 2008-06-16 18:59:30 UTC (rev 779) @@ -42,5 +42,29 @@ return sprintf('%02x%02x%02x', @color_pieces); } +=head2 format_time + +Given a number of seconds, format it as string of the format +C<HH:MM:SS> or C<MM:SS> or C<SS>. + + Smolder::Util::format_time(1000); # prints 16:40 + Smolder::Util::format_time(35); # prints 35 + Smolder::Util::format_time(100); # prints 1:40 + +=cut + +sub format_time { + my $secs = shift; + return $secs if $secs < 60; + my $hour = int($secs/3600); + my $min = int(($secs %3600)/60); + my $sec = $secs % 60; + if( $hour ) { + return sprintf('%i:%2i:%2i', $hour, $min, $sec); + } elsif( $min ) { + return sprintf('%i:%2i', $min, $sec); + } +} + 1; Modified: trunk/templates/Developer/Projects/smoke_report_details.tmpl =================================================================== --- trunk/templates/Developer/Projects/smoke_report_details.tmpl 2008-06-16 15:53:46 UTC (rev 778) +++ trunk/templates/Developer/Projects/smoke_report_details.tmpl 2008-06-16 18:59:30 UTC (rev 779) @@ -12,7 +12,7 @@ [% END %] #[% report.id %] Added [% report.added.strftime('%D %l:%M %p') %] by [% report.developer.username | html %] [% IF report.tags.size %]<em>([% report.tags.join(', ') | html %])</em>[% END %] - [% IF report.duration %] - [% report.duration %] secs[% END %] + [% IF report.duration %]([% report.duration | format_time %])[% END %] </div> <div class="content[% IF report.invalid %] invalid[% END %]" style="position: relative"> Modified: trunk/templates/TAP/full_report.tmpl =================================================================== --- trunk/templates/TAP/full_report.tmpl 2008-06-16 15:53:46 UTC (rev 778) +++ trunk/templates/TAP/full_report.tmpl 2008-06-16 18:59:30 UTC (rev 779) @@ -8,7 +8,7 @@ [% IF report.duration %] <tr class="[% odd_even %]"> <th>Duration</th> - <td>[% report.duration | format_number %] secs</td> + <td>[% report.duration | format_time %]</td> </tr> [% END %] [% IF report.platform %] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |