aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Youri/Check/Output/File/Format/Text.pm
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-08-04 16:45:06 +0000
committerFlorent Villard <warly@mandriva.com>2006-08-04 16:45:06 +0000
commit0a7ef4aa1b338a6c23dccd0db15086596f05a22a (patch)
tree620105c88261aa086535f04d1ca5fba94cb4cbbf /lib/Youri/Check/Output/File/Format/Text.pm
parent1fec4f0cac5732229070c4ad2e24c01ba2bab51b (diff)
downloadmga-youri-core-0a7ef4aa1b338a6c23dccd0db15086596f05a22a.tar
mga-youri-core-0a7ef4aa1b338a6c23dccd0db15086596f05a22a.tar.gz
mga-youri-core-0a7ef4aa1b338a6c23dccd0db15086596f05a22a.tar.bz2
mga-youri-core-0a7ef4aa1b338a6c23dccd0db15086596f05a22a.tar.xz
mga-youri-core-0a7ef4aa1b338a6c23dccd0db15086596f05a22a.zip
imported initial version of youri svn
Diffstat (limited to 'lib/Youri/Check/Output/File/Format/Text.pm')
-rw-r--r--lib/Youri/Check/Output/File/Format/Text.pm88
1 files changed, 88 insertions, 0 deletions
diff --git a/lib/Youri/Check/Output/File/Format/Text.pm b/lib/Youri/Check/Output/File/Format/Text.pm
new file mode 100644
index 0000000..458c75e
--- /dev/null
+++ b/lib/Youri/Check/Output/File/Format/Text.pm
@@ -0,0 +1,88 @@
+# $Id: Text.pm 867 2006-04-11 20:34:56Z guillomovitch $
+package Youri::Check::Output::File::Format::Text;
+
+=head1 NAME
+
+Youri::Check::Output::File::Format::Text - File text format support
+
+=head1 DESCRIPTION
+
+This format plugin for L<Youri::Check::Output::File> provides text format
+support.
+
+=cut
+
+use warnings;
+use strict;
+use Carp;
+use base 'Youri::Check::Output::File::Format';
+
+sub extension {
+ return 'txt';
+}
+
+sub get_report {
+ my ($self, $time, $title, $iterator, $type, $columns, $links, $maintainer) = @_;
+
+ my $content;
+ $content .= $title;
+ $content .= "\n";
+
+ my $lead_columns = [
+ $maintainer ?
+ qw/package media/ :
+ qw/package media maintainer/
+ ];
+ my @results;
+ $content .= join("\t", @$lead_columns, @$columns) . "\n";
+ while (my $result = $iterator->get_result()) {
+ if (@results && $result->{package} ne $results[0]->{package}) {
+ $content .= $self->_get_formated_results(
+ $lead_columns,
+ $columns,
+ \@results
+ );
+ @results = ();
+ }
+ push(@results, $result);
+ }
+ $content .= $self->_get_formated_results(
+ $lead_columns,
+ $columns,
+ \@results
+ );
+
+ $content .= "\n";
+ $content .= "Page generated $time\n";
+
+ return \$content;
+}
+
+sub _get_formated_results {
+ my ($self, $lead_columns, $columns, $results) = @_;
+
+ my $content;
+ $content .= join(
+ "\t",
+ (map { $results->[0]->{$_} || '' } @$lead_columns),
+ (map { $results->[0]->{$_} || '' } @$columns)
+ ) . "\n";
+ for my $i (1 .. $#$results) {
+ $content .= join(
+ "\t",
+ (map { '' } @$lead_columns),
+ (map { $results->[$i]->{$_} || '' } @$columns)
+ ) . "\n";
+ }
+ return $content;
+}
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2002-2006, YOURI project
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
+1;