summaryrefslogtreecommitdiff
path: root/lib/CPAN
diff options
context:
space:
mode:
authorDavid Golden <dagolden@cpan.org>2008-01-19 01:02:01 +0000
committerDavid Golden <dagolden@cpan.org>2008-01-19 01:02:01 +0000
commit9b4d96ded9d6d4d3277c07322aad8b7795ec9f44 (patch)
tree4ed589762c55ab2ee931e9e0b210460bd0b0c5b8 /lib/CPAN
parent975724567c8a1ee0ec10b5834b4ba1f8737b1be3 (diff)
- added rudimentary have_tested function to History.pm
- removed _format_distname in favor of CPAN::Distribution->base_id - tweaked edit_report prompt for clarity - stripped unused "$subject" argument in some History.pm functions - added more verbosity to critic output - added base_id to MockCPANDist - updated copyright year to include 2008 git-svn-id: https://dagolden.googlecode.com/svn/CPAN-Reporter/trunk@1605 dfce27d5-b31c-0410-bb09-030b4413eeba
Diffstat (limited to 'lib/CPAN')
-rw-r--r--lib/CPAN/Reporter.pm15
-rw-r--r--lib/CPAN/Reporter.pod2
-rw-r--r--lib/CPAN/Reporter/API.pm2
-rw-r--r--lib/CPAN/Reporter/API.pod2
-rw-r--r--lib/CPAN/Reporter/Config.pm10
-rw-r--r--lib/CPAN/Reporter/Config.pod2
-rw-r--r--lib/CPAN/Reporter/FAQ.pm2
-rw-r--r--lib/CPAN/Reporter/FAQ.pod2
-rw-r--r--lib/CPAN/Reporter/History.pm92
-rw-r--r--lib/CPAN/Reporter/History.pod50
10 files changed, 143 insertions, 36 deletions
diff --git a/lib/CPAN/Reporter.pm b/lib/CPAN/Reporter.pm
index abb57a7..eef0db4 100644
--- a/lib/CPAN/Reporter.pm
+++ b/lib/CPAN/Reporter.pm
@@ -568,17 +568,6 @@ sub _env_report {
}
#--------------------------------------------------------------------------#
-# _format_distname
-#--------------------------------------------------------------------------#
-
-sub _format_distname {
- my $dist = shift;
- my $basename = basename( $dist->pretty_id );
- $basename =~ s/(\.tar\.(?:gz|bz2)|\.tgz|\.zip)$//i;
- return $basename;
-}
-
-#--------------------------------------------------------------------------#
# _has_recursive_make
#
# Ignore Makefile.PL in t directories
@@ -619,7 +608,7 @@ sub _init_result {
exit_value => $exit_value,
# Note: pretty_id is like "DAGOLDEN/CPAN-Reporter-0.40.tar.gz"
dist_basename => basename($dist->pretty_id),
- dist_name => _format_distname( $dist ),
+ dist_name => $dist->base_id,
};
# Used in messages to user
@@ -1373,7 +1362,7 @@ David A. Golden (DAGOLDEN)
= COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter.pod b/lib/CPAN/Reporter.pod
index 42b223e..3bfc275 100644
--- a/lib/CPAN/Reporter.pod
+++ b/lib/CPAN/Reporter.pod
@@ -208,7 +208,7 @@ David A. Golden (DAGOLDEN)
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/API.pm b/lib/CPAN/Reporter/API.pm
index 3ce1b20..ae60d1a 100644
--- a/lib/CPAN/Reporter/API.pm
+++ b/lib/CPAN/Reporter/API.pm
@@ -113,7 +113,7 @@ David A. Golden (DAGOLDEN)
= COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/API.pod b/lib/CPAN/Reporter/API.pod
index 43e98e9..a57c16b 100644
--- a/lib/CPAN/Reporter/API.pod
+++ b/lib/CPAN/Reporter/API.pod
@@ -119,7 +119,7 @@ David A. Golden (DAGOLDEN)
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/Config.pm b/lib/CPAN/Reporter/Config.pm
index c38b1b0..bb1e182 100644
--- a/lib/CPAN/Reporter/Config.pm
+++ b/lib/CPAN/Reporter/Config.pm
@@ -218,12 +218,12 @@ HERE
},
edit_report => {
default => 'default:ask/no pass/na:no',
- prompt => "Do you want to edit the test report?",
+ prompt => "Do you want to review or edit the test report?",
validate => \&_validate_grade_action_pair,
info => <<'HERE',
-Before test reports are sent, you may want to edit the test report
-and add additional comments about the result or about your system or
-Perl configuration. By default, CPAN::Reporter will ask after
+Before test reports are sent, you may want to review or edit the test
+report and add additional comments about the result or about your system
+or Perl configuration. By default, CPAN::Reporter will ask after
each report is generated whether or not you would like to edit the
report. This option takes "grade:action" pairs.
HERE
@@ -665,7 +665,7 @@ David A. Golden (DAGOLDEN)
= COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/Config.pod b/lib/CPAN/Reporter/Config.pod
index 8056fc9..0a6d4d6 100644
--- a/lib/CPAN/Reporter/Config.pod
+++ b/lib/CPAN/Reporter/Config.pod
@@ -265,7 +265,7 @@ David A. Golden (DAGOLDEN)
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/FAQ.pm b/lib/CPAN/Reporter/FAQ.pm
index b9d7c8d..73f267c 100644
--- a/lib/CPAN/Reporter/FAQ.pm
+++ b/lib/CPAN/Reporter/FAQ.pm
@@ -116,7 +116,7 @@ David A. Golden (DAGOLDEN)
= COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/FAQ.pod b/lib/CPAN/Reporter/FAQ.pod
index ed41d9d..744f8af 100644
--- a/lib/CPAN/Reporter/FAQ.pod
+++ b/lib/CPAN/Reporter/FAQ.pod
@@ -122,7 +122,7 @@ David A. Golden (DAGOLDEN)
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/History.pm b/lib/CPAN/Reporter/History.pm
index 794827b..eaa9903 100644
--- a/lib/CPAN/Reporter/History.pm
+++ b/lib/CPAN/Reporter/History.pm
@@ -2,6 +2,7 @@ package CPAN::Reporter::History;
$VERSION = '1.07_02'; ## no critic
use strict;
use Config;
+use Carp;
use Fcntl qw/:flock/;
use File::HomeDir ();
use File::Path (qw/mkpath/);
@@ -82,6 +83,32 @@ BEGIN {
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
+# have_tested
+#
+# search for dist in history file -- takes dist named argument that is
+# either a dist->base_id
+#--------------------------------------------------------------------------#
+
+sub have_tested { ## no critic RequireArgUnpacking
+ croak "arguments to have_tested() must be key value pairs"
+ if @_ % 2;
+ my %args = @_;
+
+ my @found;
+ my $history = _open_history_file('<') or return;
+ flock $history, LOCK_SH;
+ <$history>; # throw away format line;
+ while ( defined (my $line = <$history>) ) {
+ my $fields = _split_history( $line ) or next;
+ push @found, $fields if $fields->{dist} eq $args{dist};
+ }
+ $history->close;
+ return @found;
+}
+
+
+
+#--------------------------------------------------------------------------#
# Private methods
#--------------------------------------------------------------------------#
@@ -97,8 +124,8 @@ sub _format_history {
my $grade = uc $result->{grade};
my $dist_name = $result->{dist_name};
my $perlver = _format_perl_version();
- my $arch = "$Config{archname} $Config{osvers}";
- return "$phase $grade $dist_name ($perlver) $arch\n";
+ my $platform = "$Config{archname} $Config{osvers}";
+ return "$phase $grade $dist_name ($perlver) $platform\n";
}
#--------------------------------------------------------------------------#
@@ -137,8 +164,8 @@ sub _get_old_history_file {
#--------------------------------------------------------------------------#
sub _is_duplicate {
- my ($result, $subject) = @_;
- my $log_line = _format_history( $result, $subject );
+ my ($result) = @_;
+ my $log_line = _format_history( $result );
my $history = _open_history_file('<') or return;
my $found = 0;
flock $history, LOCK_SH;
@@ -214,6 +241,31 @@ sub _record_history {
return;
}
+#--------------------------------------------------------------------------#
+# _split_history
+#
+# splits lines created with _format_history. Returns hash ref with
+# phase, grade, dist, perl, platform
+#--------------------------------------------------------------------------#
+
+sub _split_history {
+ my ($line) = @_;
+ my %fields;
+ @fields{qw/phase grade dist perl platform/} =
+ $line =~ m{
+ ^(\S+) \s+ # phase
+ (\S+) \s+ # grade
+ (\S+) \s+ # dist
+ \( [^)]+ \) \s+ # (perl)
+ (.+)$ # platform
+ }xms;
+
+ # return nothing if parse fails
+ return if scalar keys %fields == 0;# grep { ! defined($_) } values %fields;
+ # otherwise return hashref
+ return \%fields;
+}
+
1;
__END__
@@ -229,9 +281,33 @@ This documentation refers to version %%VERSION%%
= DESCRIPTION
-Currently, all methods are private. Future versions may add methods to
-allow programs outside CPAN::Reporter to query a CPAN::Reporter
-history file.
+Interface for interacting with the CPAN::Reporter history file. Most
+methods are private for use only within CPAN::Reporter itself.
+
+However, a public function is provided to query the history file for
+results for a particular distribution.
+
+= USAGE
+
+== {have_tested()}
+
+ @results = CPAN::Reporter::History::have_tested(
+ dist => 'Dist-Name-1.23'
+ );
+
+The {dist} argument should be the distribution tarball name without
+any filename suffix. From a {CPAN::Distribution} object, this is provided
+by the {base_id} method.
+
+If the named distribution is found in the CPAN::Reporter history file, this
+function returns an array of hashes representing each test result. Fields in
+the hash include:
+
+* {dist} -- the base id
+* {phase} -- phase the report was generated: either 'PL', 'make' or 'test'
+* {grade} -- CPAN Testers grade: 'PASS', 'FAIL', 'NA' or 'UNKNOWN'
+* {perl} -- perl version and patchlevel (if one exists)
+* {platform} -- architecture name and OS version string
= SEE ALSO
@@ -244,7 +320,7 @@ David A. Golden (DAGOLDEN)
= COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/CPAN/Reporter/History.pod b/lib/CPAN/Reporter/History.pod
index b8444fd..48519e2 100644
--- a/lib/CPAN/Reporter/History.pod
+++ b/lib/CPAN/Reporter/History.pod
@@ -12,9 +12,51 @@ This documentation refers to version 1.07_02
=head1 DESCRIPTION
-Currently, all methods are private. Future versions may add methods to
-allow programs outside CPAN::Reporter to query a CPAN::Reporter
-history file.
+Interface for interacting with the CPAN::Reporter history file. Most
+methods are private for use only within CPAN::Reporter itself.
+
+However, a public function is provided to query the history file for
+results for a particular distribution.
+
+=head1 USAGE
+
+=head2 C<<< have_tested() >>>
+
+ @results = CPAN::Reporter::History::have_tested(
+ dist => 'Dist-Name-1.23'
+ );
+
+The C<<< dist >>> argument should be the distribution tarball name without
+any filename suffix. From a C<<< CPAN::Distribution >>> object, this is provided
+by the C<<< base_id >>> method.
+
+If the named distribution is found in the CPAN::Reporter history file, this
+function returns an array of hashes representing each test result. Fields in
+the hash include:
+
+=over
+
+=item *
+
+C<<< dist >>> -- the base id
+
+=item *
+
+C<<< phase >>> -- phase the report was generated: either 'PL', 'make' or 'test'
+
+=item *
+
+C<<< grade >>> -- CPAN Testers grade: 'PASS', 'FAIL', 'NA' or 'UNKNOWN'
+
+=item *
+
+C<<< perl >>> -- perl version and patchlevel (if one exists)
+
+=item *
+
+C<<< platform >>> -- architecture name and OS version string
+
+=back
=head1 SEE ALSO
@@ -36,7 +78,7 @@ David A. Golden (DAGOLDEN)
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2006, 2007 by David A. Golden
+Copyright (c) 2006, 2007, 2008 by David A. Golden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.