[Bps-public-commit] r12916 - in Module-Versions-Report: . lib/Module lib/Module/Versions t
ruz at bestpractical.com
ruz at bestpractical.com
Thu Jun 5 10:53:19 EDT 2008
Author: ruz
Date: Thu Jun 5 10:53:19 2008
New Revision: 12916
Added:
Module-Versions-Report/ChangeLog
Module-Versions-Report/MANIFEST
Module-Versions-Report/MANIFEST.SKIP
Module-Versions-Report/META.yml
Module-Versions-Report/Makefile.PL
Module-Versions-Report/README
Module-Versions-Report/lib/
Module-Versions-Report/lib/Module/
Module-Versions-Report/lib/Module/Versions/
Module-Versions-Report/lib/Module/Versions/Report.pm
Module-Versions-Report/t/
Module-Versions-Report/t/00about.t
Module-Versions-Report/t/10load.t
Log:
* import version 1.03
Added: Module-Versions-Report/ChangeLog
==============================================================================
--- (empty file)
+++ Module-Versions-Report/ChangeLog Thu Jun 5 10:53:19 2008
@@ -0,0 +1,17 @@
+Revision history for Perl module Module::Versions::Report
+ Time-stamp: "2003-06-21 23:17:33 AHDT"
+
+2007-05-21 Ruslan U. Zakirov <ruz at bestpractical.com>
+
+ * Release 1.03
+ * count modules instead of records in tables
+ * update docs
+
+2003-06-21 Sean M. Burke <sburke at cpan.org>
+
+ * Release 1.02: First public release
+
+ (Before this it just sat around on my hard drive for a year,
+ as I fiddled with its docs, and vacillated on which name to
+ release it as.)
+
Added: Module-Versions-Report/MANIFEST
==============================================================================
--- (empty file)
+++ Module-Versions-Report/MANIFEST Thu Jun 5 10:53:19 2008
@@ -0,0 +1,9 @@
+ChangeLog
+MANIFEST
+MANIFEST.SKIP
+Makefile.PL
+README
+lib/Module/Versions/Report.pm
+t/00about.t
+t/10load.t
+META.yml Module meta-data (added by MakeMaker)
Added: Module-Versions-Report/MANIFEST.SKIP
==============================================================================
--- (empty file)
+++ Module-Versions-Report/MANIFEST.SKIP Thu Jun 5 10:53:19 2008
@@ -0,0 +1,7 @@
+^MANIFEST\.bak$
+Makefile(\.old)?$
+\.rej$
+CVS
+blib
+~
+
Added: Module-Versions-Report/META.yml
==============================================================================
--- (empty file)
+++ Module-Versions-Report/META.yml Thu Jun 5 10:53:19 2008
@@ -0,0 +1,11 @@
+--- #YAML:1.0
+name: Module-Versions-Report
+version: 1.03
+abstract: report versions of all modules in memory
+license: ~
+generated_by: ExtUtils::MakeMaker version 6.32
+distribution_type: module
+requires:
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.2.html
+ version: 1.2
Added: Module-Versions-Report/Makefile.PL
==============================================================================
--- (empty file)
+++ Module-Versions-Report/Makefile.PL Thu Jun 5 10:53:19 2008
@@ -0,0 +1,24 @@
+# This -*- perl -*- script writes the Makefile for Module::Versions::Report
+# Time-stamp: "2003-06-21 23:27:37 AHDT"
+require 5.004;
+use strict;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Module-Versions-Report',
+ VERSION_FROM => 'lib/Module/Versions/Report.pm',
+ ABSTRACT => 'report versions of all modules in memory',
+ 'dist' => { COMPRESS => 'gzip -6f', SUFFIX => 'gz', },
+);
+
+package MY;
+
+sub libscan
+{ # Determine things that should *not* be installed
+ my($self, $path) = @_;
+ return '' if $path =~ m/~/;
+ $path;
+}
+
+__END__
+
Added: Module-Versions-Report/README
==============================================================================
--- (empty file)
+++ Module-Versions-Report/README Thu Jun 5 10:53:19 2008
@@ -0,0 +1,124 @@
+README for Module::Report::Versions
+ Time-stamp: "2003-06-21 23:18:00 AHDT"
+
+NAME
+ Module::Versions::Report -- report versions of all modules in memory
+
+SYNOPSIS
+ use Module::Versions::Report;
+
+ ...and any code you want...
+
+ This will run all your code normally, but then as the Perl interpreter
+ is about to exit, it will print something like:
+
+ Perl v5.6.1 under MSWin32.
+ Modules in memory:
+ attributes;
+ AutoLoader v5.58;
+ Carp;
+ Config;
+ DynaLoader v1.04;
+ Exporter v5.562;
+ Module::Versions::Report v1.01;
+ HTML::Entities v1.22;
+ HTML::HeadParser v2.15;
+ HTML::Parser v3.25;
+ [... and whatever other modules were loaded that session...]
+
+ Consider its use from the command line:
+
+ % perl -MModule::Versions::Report -MLWP -e 1
+
+ Perl v5.6.1 under MSWin32.
+ Modules in memory:
+ attributes;
+ AutoLoader v5.58;
+ [...]
+
+DESCRIPTION
+ I often get email from someone reporting a bug in a module I've written.
+ I email back, asking what version of the module it is, what version of
+ Perl on what OS, and sometimes what version of some relevent third
+ library (like XML::Parser). They reply, saying "Perl 5". I say "I need
+ the exact version, as reported by "perl -v"". They tell me. And I say
+ "I, uh, also asked about the version of my module and XML::Parser [or
+ whatever]". They say "Oh yeah. It's 2.27". "Is that my module or
+ XML::Parser?" "XML::Parser." "OK, and what about my module's version?"
+ "Ohyeah. That's 3.11." By this time, days have passed, and what should
+ have been a simple operation -- reporting the version of Perl and
+ relevent modules, has been needlessly complicated.
+
+ This module is for simplifying that task. If you add "use
+ Module::Versions::Report;" to a program (especially handy if your
+ program is one that demonstrates a bug in some module), then when the
+ program has finished running, you well get a report detailing the all
+ modules in memory, and noting the version of each (for modules that
+ defined a $VERSION, at least).
+
+COPYRIGHT AND DISCLAIMER
+ Copyright 2001-2003 Sean M. Burke. This library is free software; you
+ can redistribute it and/or modify it under the same terms as Perl
+ itself.
+
+ This program is distributed in the hope that it will be useful, but
+ without any warranty; without even the implied warranty of
+ merchantability or fitness for a particular purpose.
+
+AUTHOR
+ Sean M. Burke, <sburke at cpan.org>
+
+
+
+PREREQUISITES
+
+This suite requires Perl 5.
+
+
+INSTALLATION
+
+You install Module::Versions::Report, as you would install any Perl module
+distribution, by running these commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+If you want to install a private copy of Module::Versions::Report in
+your home directory, then you should try to produce the initial Makefile
+with something like this command:
+
+ perl Makefile.PL LIB=~/perl
+
+See perldoc perlmodinstall for more information.
+
+
+DOCUMENTATION
+
+See the pod in Module::Versions::Report.
+
+
+SUPPORT
+
+Questions, bug reports, useful code bits, and suggestions for
+Worms should be sent to me at sburke at cpan.org
+
+
+AVAILABILITY
+
+The latest version of Module::Versions::Report is available from the
+Comprehensive Perl Archive Network (CPAN). Visit
+<http://www.perl.com/CPAN/> to find a CPAN site near you.
+
+
+COPYRIGHT
+
+Copyright 2001-2003, Sean M. Burke <sburke at cpan.org>, all rights
+reserved. This program is free software; you can redistribute it
+and/or modify it under the same terms as Perl itself.
+
+
+AUTHOR
+
+Sean M. Burke <sburke at cpan.org>
Added: Module-Versions-Report/lib/Module/Versions/Report.pm
==============================================================================
--- (empty file)
+++ Module-Versions-Report/lib/Module/Versions/Report.pm Thu Jun 5 10:53:19 2008
@@ -0,0 +1,183 @@
+
+require 5;
+package Module::Versions::Report;
+$VERSION = '1.03';
+$PACKAGES_LIMIT = 1000;
+
+=head1 NAME
+
+Module::Versions::Report -- report versions of all modules in memory
+
+=head1 SYNOPSIS
+
+ use Module::Versions::Report;
+
+ ...and any code you want...
+
+This will run all your code normally, but then as the Perl
+interpreter is about to exit, it will print something
+like:
+
+ Perl v5.6.1 under MSWin32.
+ Modules in memory:
+ attributes;
+ AutoLoader v5.58;
+ Carp;
+ Config;
+ DynaLoader v1.04;
+ Exporter v5.562;
+ Module::Versions::Report v1.01;
+ HTML::Entities v1.22;
+ HTML::HeadParser v2.15;
+ HTML::Parser v3.25;
+ [... and whatever other modules were loaded that session...]
+
+Consider its use from the command line:
+
+ % perl -MModule::Versions::Report -MLWP -e 1
+
+ Perl v5.6.1 under MSWin32.
+ Modules in memory:
+ attributes;
+ AutoLoader v5.58;
+ [...]
+
+=head1 DESCRIPTION
+
+I often get email from someone reporting a bug in a module I've
+written. I email back, asking what version of the module it is,
+what version of Perl on what OS, and sometimes what version of
+some relevent third library (like XML::Parser). They reply,
+saying "Perl 5". I say "I need the exact version, as reported
+by C<perl -v>". They tell me. And I say "I, uh, also asked about
+the version of my module and XML::Parser [or whatever]". They say
+"Oh yeah. It's 2.27". "Is that my module or XML::Parser?"
+"XML::Parser." "OK, and what about my module's
+version?" "Ohyeah. That's 3.11." By this time, days have passed,
+and what should have been a simple operation -- reporting the version
+of Perl and relevent modules, has been needlessly complicated.
+
+This module is for simplifying that task. If you add "use
+Module::Versions::Report;" to a program (especially handy if your
+program is one that demonstrates a bug in some module), then when the
+program has finished running, you well get a report detailing the all
+modules in memory, and noting the version of each (for modules that
+defined a C<$VERSION>, at least).
+
+=head1 USING
+
+=head2 Importing
+
+If this package is imported then END block is set, and report printed to
+stdout on a program exit, so use C<use Module::Versions::Report;> if you
+need a report on exit or C<use Module::Versions::Report ();> otherwise
+and call report or print_report functions yourself.
+
+=cut
+
+$Already = 0;
+
+sub import {
+ # so "use Module::Versions::Report;" sets up the END block, but
+ # a mere "use Module::Versions::Report ();" doesn't.
+ unless($Already) {
+ eval 'END { print_report(); }';
+ die "Extremely unexpected error in ", __PACKAGE__, ": $@" if $@;
+ $Already = 1;
+ }
+ return;
+}
+
+=head2 report and print_report functions
+
+The first one returns preformatted report as a string, the latter outputs
+a report to stdout.
+
+=cut
+
+sub report {
+ my @out;
+ push @out,
+ "\n\nPerl v",
+ defined($^V) ? sprintf('%vd', $^V) : $],
+ " under $^O ",
+ (defined(&Win32::BuildNumber) and defined &Win32::BuildNumber())
+ ? ("(Win32::BuildNumber ", &Win32::BuildNumber(), ")") : (),
+ (defined $MacPerl::Version)
+ ? ("(MacPerl version $MacPerl::Version)") : (),
+ "\n"
+ ;
+
+ # Ugly code to walk the symbol tables:
+ my %v;
+ my @stack = (''); # start out in %::
+ my $this;
+ my $count = 0;
+ my $pref;
+ while(@stack) {
+ $this = shift @stack;
+ die "Too many packages?" if $count > $PACKAGES_LIMIT;
+ next if exists $v{$this};
+ next if $this eq 'main'; # %main:: is %::
+
+ #print "Peeking at $this => ${$this . '::VERSION'}\n";
+
+ if(defined ${$this . '::VERSION'} ) {
+ $v{$this} = ${$this . '::VERSION'};
+ $count++;
+ } elsif(
+ defined *{$this . '::ISA'} or defined &{$this . '::import'}
+ or ($this ne '' and grep defined *{$_}{'CODE'}, values %{$this . "::"})
+ # If it has an ISA, an import, or any subs...
+ ) {
+ # It's a class/module with no version.
+ $v{$this} = undef;
+ $count++;
+ } else {
+ # It's probably an unpopulated package.
+ ## $v{$this} = '...';
+ }
+
+ $pref = length($this) ? "$this\::" : '';
+ push @stack, map m/^(.+)::$/ ? "$pref$1" : (), keys %{$this . '::'};
+ #print "Stack: @stack\n";
+ }
+ push @out, " Modules in memory:\n";
+ delete @v{'', '<none>'};
+ foreach my $p (sort {lc($a) cmp lc($b)} keys %v) {
+ #$indent = ' ' x (2 + ($p =~ tr/:/:/));
+ push @out, ' ',
+ # $indent,
+ $p, defined($v{$p}) ? " v$v{$p};\n" : ";\n";
+ }
+ push @out, sprintf "[at %s (local) / %s (GMT)]\n",
+ scalar(localtime), scalar(gmtime);
+ return join '', @out;
+}
+
+sub print_report { print '', report(); }
+
+1;
+
+=head1 COPYRIGHT AND DISCLAIMER
+
+Copyright 2001-2003 Sean M. Burke. This library is free software; you
+can redistribute it and/or modify it under the same terms as Perl
+itself.
+
+This program is distributed in the hope that it will be useful, but
+without any warranty; without even the implied warranty of
+merchantability or fitness for a particular purpose.
+
+=head1 MAINTAINER
+
+Ruslan U. Zakirov E<lt>ruz at bestpractical.comE<gt>
+
+=head1 AUTHOR
+
+Sean M. Burke, E<lt>sburke at cpan.orgE<gt>
+
+=cut
+
+__END__
+
Added: Module-Versions-Report/t/00about.t
==============================================================================
--- (empty file)
+++ Module-Versions-Report/t/00about.t Thu Jun 5 10:53:19 2008
@@ -0,0 +1,28 @@
+
+require 5;
+use Test;
+BEGIN { plan tests => 1; }
+use Module::Versions::Report ();
+
+print "#\n#\n",
+ "# Module::Versions::Report v$Module::Versions::Report::VERSION\n",
+ "#\n#\n",
+;
+
+print "# Running under perl version $] for $^O",
+ (chr(65) eq 'A') ? "\n" : " in a non-ASCII world\n";
+
+print "# Win32::BuildNumber ", &Win32::BuildNumber(), "\n"
+ if defined(&Win32::BuildNumber) and defined &Win32::BuildNumber();
+
+print "# MacPerl verison $MacPerl::Version\n"
+ if defined $MacPerl::Version;
+
+printf
+ "# Current time local: %s\n# Current time GMT: %s\n",
+ scalar( gmtime($^T)), scalar(localtime($^T));
+
+print "# Using Test.pm v", $Test::VERSION || "?", "\n";
+
+ok 1;
+
Added: Module-Versions-Report/t/10load.t
==============================================================================
--- (empty file)
+++ Module-Versions-Report/t/10load.t Thu Jun 5 10:53:19 2008
@@ -0,0 +1,55 @@
+
+require 5;
+use strict;
+use Test;
+my @modules;
+
+BEGIN {
+ @modules =
+ # Modules that have a $VERSION each, and have been in core for ages
+ qw(
+ Fcntl File::Basename File::Copy File::Path FileHandle FindBin
+ Getopt::Long IO::File POSIX Text::Tabs
+ );
+ my $testcount = 2 + 3 * @modules;
+ plan tests => $testcount;
+ print "# ~ ~ ~ Expecting $testcount tests ~ ~ ~\n";
+}
+
+use Module::Versions::Report ();
+
+
+ok 1;
+foreach my $m (@modules) {
+ print "# requiring $m...\n";
+ eval "require $m;";
+ die "Can't require $m: $@\nAborting" if $@;
+ ok 1;
+}
+
+my $out = Module::Versions::Report::report();
+
+{ my $o = $out; $o =~ s/^/# /mg; print "#\n#\n# Output:\n$o#\n"; }
+
+foreach my $m (@modules) {
+ my $mq = quotemeta($m);
+ my $mv = quotemeta(do { no strict 'refs'; ${"$m\::VERSION"} || 'WHA' } );
+ if($out =~ m/$mq/) {
+ ok 1;
+ } else {
+ ok 0;
+ print "# Can't find $mq in output\n";
+ }
+
+ if($out =~ m/$mv/) {
+ ok 1;
+ } else {
+ ok 0;
+ print "# Can't find $mv in output\n";
+ }
+
+}
+
+print "# Byebye!\n";
+ok 1;
+
More information about the Bps-public-commit
mailing list