Committed by "David E. Wheeler" <[email protected]>

Subject: [DBD::Pg 2/2] Update App::Info.

---
 t/lib/App/Info.pm                  |  75 +++++++++++----------
 t/lib/App/Info/Handler.pm          |  41 +++++++-----
 t/lib/App/Info/Handler/Print.pm    |   2 +-
 t/lib/App/Info/Handler/Prompt.pm   |  17 +++--
 t/lib/App/Info/RDBMS.pm            |  17 +++--
 t/lib/App/Info/RDBMS/PostgreSQL.pm |  65 ++++++++----------
 t/lib/App/Info/Request.pm          |  33 ++++++++--
 t/lib/App/Info/Util.pm             | 132 ++++++++++++++++++++++++++-----------
 8 files changed, 237 insertions(+), 145 deletions(-)

diff --git a/t/lib/App/Info.pm b/t/lib/App/Info.pm
index 42ad638..ebb83cd 100644
--- a/t/lib/App/Info.pm
+++ b/t/lib/App/Info.pm
@@ -21,10 +21,10 @@ App::Info - Information about software packages on a system
 =head1 DESCRIPTION
 
 App::Info is an abstract base class designed to provide a generalized
-interface for subclasses that provide metadata about software packages
+interface for subclasses that provide meta data about software packages
 installed on a system. The idea is that these classes can be used in Perl
 application installers in order to determine whether software dependencies
-have been fulfilled, and to get necessary metadata about those software
+have been fulfilled, and to get necessary meta data about those software
 packages.
 
 App::Info provides an event model for handling events triggered by App::Info
@@ -54,7 +54,7 @@ use App::Info::Handler;
 use App::Info::Request;
 use vars qw($VERSION);
 
-$VERSION = '0.45';
+$VERSION = '0.57';
 
 ##############################################################################
 ##############################################################################
@@ -129,7 +129,7 @@ parameters that can be passed to C<new()> are:
 =item search_exe_names
 
 An array reference of possible names for binary executables. These may be used
-by subclases to search for application programs that can be used to retreive
+by subclasses to search for application programs that can be used to retrieve
 application information, such as version numbers. The subclasses generally
 provide reasonable defaults for most cases.
 
@@ -142,13 +142,13 @@ addition to and in preference to the defaults used by 
each subclass.
 =item search_lib_names
 
 An array reference of possible names for library files. These may be used by
-subclases to search for library files for the application. The subclasses
+subclasses to search for library files for the application. The subclasses
 generally provide reasonable defaults for most cases.
 
 =item search_so_lib_names
 
 An array reference of possible names for shared object library files. These
-may be used by subclases to search for shared object library files for the
+may be used by subclasses to search for shared object library files for the
 application. The subclasses generally provide reasonable defaults for most
 cases.
 
@@ -162,7 +162,7 @@ subclass.
 =item search_inc_names
 
 An array reference of possible names for include files. These may be used by
-subclases to search for include files for the application. The subclasses
+subclasses to search for include files for the application. The subclasses
 generally provide reasonable defaults for most cases.
 
 =item search_inc_dirs
@@ -223,10 +223,10 @@ sub new {
 ##############################################################################
 ##############################################################################
 
-=head2 Metadata Object Methods
+=head2 Meta Data Object Methods
 
 These are abstract methods in App::Info and must be provided by its
-subclasses. They provide the essential metadata of the software package
+subclasses. They provide the essential meta data of the software package
 supported by the App::Info subclass.
 
 =head3 key_name
@@ -410,17 +410,17 @@ sub download_url  { $croak->(shift, 'download_url') }
 =head2 Search Attributes
 
 These methods return lists of things to look for on the local file system when
-searching for appliation programs, library files, and include files. They are
+searching for application programs, library files, and include files. They are
 empty by default, since each subclass generally relies on its own settings,
-but you can add your own as preferred search parameters by specifying them
-as parameters to the C<new()> constructor.
+but you can add your own as preferred search parameters by specifying them as
+parameters to the C<new()> constructor.
 
 =head3 exe_names
 
   my @search_exe_names = $app->search_exe_names;
 
 Returns a list of possible names for an executable. Typically used by the
-C<new()> constructor to search fo an executable to execute and collect
+C<new()> constructor to search for an executable to execute and collect
 application info.
 
 =cut
@@ -602,7 +602,7 @@ sub on_error {
   my @handlers = $app->on_unknown;
   $app->on_uknown(@handlers);
 
-Unknown events are trigged when the App::Info subclass cannot find the value
+Unknown events are triggered when the App::Info subclass cannot find the value
 to be returned by a method call. By default, these events are ignored. A
 common way of handling them is to have the application prompt the user for the
 relevant data. The App::Info::Handler::Prompt class included with the
@@ -659,7 +659,7 @@ sub on_confirm {
 
 As an abstract base class, App::Info is not intended to be used directly.
 Instead, you'll use concrete subclasses that implement the interface it
-defines. These subclasses each provide the metadata necessary for a given
+defines. These subclasses each provide the meta data necessary for a given
 software package, via the interface outlined above (plus any additional
 methods the class author deems sensible for a given application).
 
@@ -708,7 +708,7 @@ the functionality you need.
 Use the methods described below to trigger events. Events are designed to
 provide a simple way for App::Info subclass developers to send status messages
 and errors, to confirm data values, and to request a value when the class
-caonnot determine a value itself. Events may optionally be handled by module
+cannot determine a value itself. Events may optionally be handled by module
 users who assign App::Info::Handler subclass objects to your App::Info
 subclass object using the event handling methods described in the L<"Event
 Handler Object Methods"> section.
@@ -861,7 +861,7 @@ App::Info::Request object passed to event handlers.
 =back
 
 This may be the event method you use most, as it should be called in every
-metadata method if you cannot provide the data needed by that method. It will
+meta data method if you cannot provide the data needed by that method. It will
 typically be the last part of the method. Here's an example demonstrating each
 of the above arguments:
 
@@ -874,7 +874,7 @@ of the above arguments:
 
 sub unknown {
     my ($self, %params) = @_;
-    my $key = delete $params{key}
+    my $key = $params{key}
       or Carp::croak("No key parameter passed to unknown()");
     # Just return the value if we've already handled this value. Ideally this
     # shouldn't happen.
@@ -902,13 +902,13 @@ sub unknown {
 This method is very similar to C<unknown()>, but serves a different purpose.
 Use this method for significant data points where you've found an appropriate
 value, but want to ensure it's really the correct value. A "significant data
-point" is usually a value essential for your class to collect metadata values.
+point" is usually a value essential for your class to collect meta data values.
 For example, you might need to locate an executable that you can then call to
 collect other data. In general, this will only happen once for an object --
 during object construction -- but there may be cases in which it is needed
 more than that. But hopefully, once you've confirmed in the constructor that
 you've found what you need, you can use that information to collect the data
-needed by all of the metadata methods and can assume that they'll be right
+needed by all of the meta data methods and can assume that they'll be right
 because that first, significant data point has been confirmed.
 
 Other than where and how often to call C<confirm()>, its use is quite similar
@@ -969,7 +969,7 @@ Here's an example usage demonstrating all of the above 
arguments:
 
 sub confirm {
     my ($self, %params) = @_;
-    my $key = delete $params{key}
+    my $key = $params{key}
       or Carp::croak("No key parameter passed to confirm()");
     return $self->{__confirm__}{$key} if exists $self->{__confirm__}{$key};
 
@@ -1075,15 +1075,15 @@ the following simple guidelines: Use C<error()> when 
you expect something to
 work and then it just doesn't (as when a file exists and should contain the
 information you seek, but then doesn't). Use C<unknown()> when you're less
 sure of your processes for finding the value, and also for any of the values
-that should be returned by any of the L<metadata object methods|"Metadata
+that should be returned by any of the L<meta data object methods|"Metadata
 Object Methods">. And of course, C<error()> would be more appropriate when you
 encounter an unexpected condition and don't think that it could be handled in
 any other way.
 
 Now, more than likely, a method such C<_find_version()> would be called by the
-C<version()> method, which is a metadata method mandated by the App::Info
+C<version()> method, which is a meta data method mandated by the App::Info
 abstract base class. This is an appropriate place to handle an unknown version
-value. Indeed, every one of your metadata methods should make use of the
+value. Indeed, every one of your meta data methods should make use of the
 C<unknown()> method. The C<version()> method then should look something like
 this:
 
@@ -1109,7 +1109,7 @@ every time, as C<unknown()> will return the same value 
every time it is called
 (as, indeed, should C<_find_version()>. But by checking for the C<version> key
 in C<$self> ourselves, we save some of the overhead.
 
-But as I said before, every metadata method should make use of the
+But as I said before, every meta data method should make use of the
 C<unknown()> method. Thus, the C<major()> method might looks something like
 this:
 
@@ -1132,7 +1132,7 @@ this:
 
 Finally, the C<confirm()> method should be used to verify core pieces of data
 that significant numbers of other methods rely on. Typically such data are
-executables or configuration files from which will be drawn other metadata.
+executables or configuration files from which will be drawn other meta data.
 Most often, such major data points will be sought in the object constructor.
 Here's an example:
 
@@ -1181,8 +1181,8 @@ the super class to construct the object first. Doing so 
allows any event
 handling arguments to set up the event handlers, so that when we call
 C<confirm()> or C<unknown()> the event will be handled as the client expects.
 
-If we needed our subclass constructor to take its own parameter argumente, the
-approach is to specify the same C<< key => $arg >> syntax as is used by
+If we needed our subclass constructor to take its own parameter argument, the
+approach is to specify the same C<key => $arg> syntax as is used by
 App::Info's C<new()> method. Say we wanted to allow clients of our App::Info
 subclass to pass in a list of alternate executable locations for us to search.
 Such an argument would most make sense as an array reference. So we specify
@@ -1212,7 +1212,7 @@ To summarize, here are some guidelines for subclassing 
App::Info.
 =item *
 
 Always subclass an App::Info category subclass. This will help to keep the
-App::Info namespace well-organized. New categories can be added as needed.
+App::Info name space well-organized. New categories can be added as needed.
 
 =item *
 
@@ -1242,7 +1242,7 @@ exceptions for fatal errors.
 
 =item *
 
-Use the C<unknown()> event triggering method when a metadata or other
+Use the C<unknown()> event triggering method when a meta data or other
 important value is unknown and you want to give any event handlers the chance
 to provide the data.
 
@@ -1273,14 +1273,19 @@ aggregated in Bundle distributions.
 
 But I get ahead of myself...
 
-=head1 BUGS
+=head1 SUPPORT
 
-Please send bug reports to <[email protected]> or file them at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info>.
+This module is stored in an open L<GitHub
+repository|http://github.com/theory/app-info/>. Feel free to fork and
+contribute!
+
+Please file bug reports via L<GitHub
+Issues|http://github.com/theory/app-info/issues/> or by sending mail to
+L<[email protected]|mailto:[email protected]>.
 
 =head1 AUTHOR
 
-David Wheeler <[email protected]>
+David E. Wheeler <[email protected]>
 
 =head1 SEE ALSO
 
@@ -1337,7 +1342,7 @@ App::Info::Handler subclasses.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under
 the same terms as Perl itself.
diff --git a/t/lib/App/Info/Handler.pm b/t/lib/App/Info/Handler.pm
index fa183ff..db9336c 100644
--- a/t/lib/App/Info/Handler.pm
+++ b/t/lib/App/Info/Handler.pm
@@ -33,7 +33,7 @@ handlers, read on!
 
 use strict;
 use vars qw($VERSION);
-$VERSION = '0.45';
+$VERSION = '0.57';
 
 my %handlers;
 
@@ -51,7 +51,7 @@ This class method may be used by App::Info::Handler 
subclasses to register
 themselves with App::Info::Handler. Multiple registrations are supported. The
 idea is that a subclass can define different functionality by specifying
 different strings that represent different modes of constructing an
-App::Info::Handler subclass object. The keys are case-sensitve, and should be
+App::Info::Handler subclass object. The keys are case-sensitive, and should be
 unique across App::Info::Handler subclasses so that many subclasses can be
 loaded and used separately. If the C<$key> is already registered,
 C<register_handler()> will throw an exception. The values are code references
@@ -131,7 +131,7 @@ __END__
 =head1 SUBCLASSING
 
 I hatched the idea of the App::Info event model with its subclassable handlers
-as a way of separating the aggregation of application metadata from writing a
+as a way of separating the aggregation of application meta data from writing a
 user interface for handling certain conditions. I felt it a better idea to
 allow people to create their own user interfaces, and instead to provide only
 a few examples. The App::Info::Handler class defines the API interface for
@@ -216,7 +216,7 @@ The final step in creating a new App::Info event handler is 
to implement the
 C<handler()> method itself. This method takes a single argument, an
 App::Info::Request object, and is expected to return true if it handled the
 request, and false if it did not. The App::Info::Request object contains all
-the metadata relevant to a request, including the type of event that triggered
+the meta data relevant to a request, including the type of event that triggered
 it; see L<App::Info::Request|App::Info::Request> for its documentation.
 
 Use the App::Info::Request object however you like to handle the request
@@ -234,23 +234,23 @@ so is up to you and the handler.
 
 For unknown and confirm events, you are expected to prompt the user for a
 value. If it's a confirm event, offer the known value (found in
-C<< $req->value >>) as a default.
+C<$req-E<gt>value>) as a default.
 
 =item *
 
-For unknown and confirm events, you are expected to call C<< $req->callback >>
-and pass in the new value. If C<< $req->callback >> returns a false value, you
-are expected to display the error message in C<< $req->error >> and prompt the
-user again. Note that C<< $req->value >> calls C<< $req->callback >>
+For unknown and confirm events, you are expected to call C<$req-E<gt>callback>
+and pass in the new value. If C<$req-E<gt>callback> returns a false value, you
+are expected to display the error message in C<$req-E<gt>error> and prompt the
+user again. Note that C<$req-E<gt>value> calls C<$req-E<gt>callback>
 internally, and thus assigns the value and returns true if
-C<< $req->callback >> returns true, and does not assign the value and returns
-false if C<< $req->callback >> returns false.
+C<$req-E<gt>callback> returns true, and does not assign the value and returns
+false if C<$req-E<gt>callback> returns false.
 
 =item *
 
 For unknown and confirm events, if you've collected a new value and
-C<< $req->callback >> returns true for that value, you are expected to assign
-the value by passing it to C<< $req->value >>. This allows App::Info to give
+C<$req-E<gt>callback> returns true for that value, you are expected to assign
+the value by passing it to C<$req-E<gt>value>. This allows App::Info to give
 the value back to the calling App::Info concrete subclass.
 
 =back
@@ -261,14 +261,19 @@ their logical examples. Consult the App::Info 
documentation of the L<event
 methods|App::Info/"Events"> for details on how App::Info constructs the
 App::Info::Request object for each event type.
 
-=head1 BUGS
+=head1 SUPPORT
 
-Please send bug reports to <[email protected]> or file them at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info>.
+This module is stored in an open L<GitHub
+repository|http://github.com/theory/app-info/>. Feel free to fork and
+contribute!
+
+Please file bug reports via L<GitHub
+Issues|http://github.com/theory/app-info/issues/> or by sending mail to
+L<[email protected]|mailto:[email protected]>.
 
 =head1 AUTHOR
 
-David Wheeler <[email protected]>
+David E. Wheeler <[email protected]>
 
 =head1 SEE ALSO
 
@@ -295,7 +300,7 @@ App::Info clients.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under 
the
 same terms as Perl itself.
diff --git a/t/lib/App/Info/Handler/Print.pm b/t/lib/App/Info/Handler/Print.pm
index 1909c3f..f8e95f0 100644
--- a/t/lib/App/Info/Handler/Print.pm
+++ b/t/lib/App/Info/Handler/Print.pm
@@ -52,7 +52,7 @@ print event messages to different filehandle.
 use strict;
 use App::Info::Handler;
 use vars qw($VERSION @ISA);
-$VERSION = '0.58';
+$VERSION = '0.57';
 @ISA = qw(App::Info::Handler);
 
 # Register ourselves.
diff --git a/t/lib/App/Info/Handler/Prompt.pm b/t/lib/App/Info/Handler/Prompt.pm
index 156d024..1471a48 100644
--- a/t/lib/App/Info/Handler/Prompt.pm
+++ b/t/lib/App/Info/Handler/Prompt.pm
@@ -43,7 +43,7 @@ events.
 use strict;
 use App::Info::Handler;
 use vars qw($VERSION @ISA);
-$VERSION = '0.45';
+$VERSION = '0.57';
 @ISA = qw(App::Info::Handler);
 
 # Register ourselves.
@@ -136,14 +136,19 @@ sub handler {
 1;
 __END__
 
-=head1 BUGS
+=head1 SUPPORT
 
-Please send bug reports to <[email protected]> or file them at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info>.
+This module is stored in an open L<GitHub
+repository|http://github.com/theory/app-info/>. Feel free to fork and
+contribute!
+
+Please file bug reports via L<GitHub
+Issues|http://github.com/theory/app-info/issues/> or by sending mail to
+L<[email protected]|mailto:[email protected]>.
 
 =head1 AUTHOR
 
-David Wheeler <[email protected]>
+David E. Wheeler <[email protected]>
 
 =head1 SEE ALSO
 
@@ -160,7 +165,7 @@ App::Info event handlers.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under 
the
 same terms as Perl itself.
diff --git a/t/lib/App/Info/RDBMS.pm b/t/lib/App/Info/RDBMS.pm
index 9d43685..248d157 100644
--- a/t/lib/App/Info/RDBMS.pm
+++ b/t/lib/App/Info/RDBMS.pm
@@ -4,7 +4,7 @@ use strict;
 use App::Info;
 use vars qw(@ISA $VERSION);
 @ISA = qw(App::Info);
-$VERSION = '0.27';
+$VERSION = '0.57';
 
 1;
 __END__
@@ -26,14 +26,19 @@ implementation.
 Currently, App::Info::RDBMS adds no more methods than those from its parent
 class, App::Info.
 
-=head1 BUGS
+=head1 SUPPORT
 
-Report all bugs via the CPAN Request Tracker at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info>.
+This module is stored in an open L<GitHub
+repository|http://github.com/theory/app-info/>. Feel free to fork and
+contribute!
+
+Please file bug reports via L<GitHub
+Issues|http://github.com/theory/app-info/issues/> or by sending mail to
+L<[email protected]|mailto:[email protected]>.
 
 =head1 AUTHOR
 
-David Wheeler <L<[email protected]|"[email protected]">>
+David E. Wheeler <[email protected]>
 
 =head1 SEE ALSO
 
@@ -42,7 +47,7 @@ L<App::Info::RDBMS::PostgreSQL|App::Info::RDBMS::PostgreSQL>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under 
the
 same terms as Perl itself.
diff --git a/t/lib/App/Info/RDBMS/PostgreSQL.pm 
b/t/lib/App/Info/RDBMS/PostgreSQL.pm
index 8a9b27c..af30501 100644
--- a/t/lib/App/Info/RDBMS/PostgreSQL.pm
+++ b/t/lib/App/Info/RDBMS/PostgreSQL.pm
@@ -26,7 +26,7 @@ methods defined by App::Info::RDBMS. Methods that trigger 
events will trigger
 them only the first time they're called (See L<App::Info|App::Info> for
 documentation on handling events). To start over (after, say, someone has
 installed PostgreSQL) construct a new App::Info::RDBMS::PostgreSQL object to
-aggregate new metadata.
+aggregate new meta data.
 
 Some of the methods trigger the same events. This is due to cross-calling of
 shared subroutines. However, any one event should be triggered no more than
@@ -42,13 +42,13 @@ use App::Info::RDBMS;
 use App::Info::Util;
 use vars qw(@ISA $VERSION);
 @ISA = qw(App::Info::RDBMS);
-$VERSION = '0.45';
+$VERSION = '0.57';
 use constant WIN32 => $^O eq 'MSWin32';
 
 my $u = App::Info::Util->new;
 my @EXES = qw(postgres createdb createlang createuser dropdb droplang
-              dropuser initdb pg_dump pg_dumpall pg_resetxlog pg_restore
-              pg_upgrade postmaster vacuumdb psql);
+              dropuser initdb pg_dump pg_dumpall pg_restore postmaster
+              vacuumdb psql);
 
 =head1 INTERFACE
 
@@ -95,12 +95,8 @@ via the C<search_exe_names> parameter). These parameters are:
 
 =item search_pg_dumpall_names
 
-=item search_pg_resetxlog_names
-
 =item search_pg_restore_names
 
-=item search_pg_upgrade_names
-
 =item search_postmaster_names
 
 =item search_psql_names
@@ -139,16 +135,16 @@ sub new {
     my @paths = $self->search_bin_dirs;
     my @exes = $self->search_exe_names;
 
-    if (my $cfg = $u->first_cat_exe(\@exes, @paths) and 
!$ENV{DBDPG_TESTINITDB}) {
+    if (my $cfg = $u->first_cat_exe(\@exes, @paths)) {
         # We found it. Confirm.
-        $self->{pg_config} = $self->confirm( key      => 'pg_config',
+        $self->{pg_config} = $self->confirm( key      => 'path to pg_config',
                                              prompt   => "Path to pg_config?",
                                              value    => $cfg,
                                              callback => sub { -x },
                                              error    => 'Not an executable');
     } else {
         # Handle an unknown value.
-        $self->{pg_config} = $self->unknown( key      => 'pg_config',
+        $self->{pg_config} = $self->unknown( key      => 'path to pg_config',
                                              prompt   => "Path to pg_config?",
                                              callback => sub { -x },
                                              error    => 'Not an executable');
@@ -293,7 +289,7 @@ sub name {
     $get_version->($self) unless $self->{'--version'};
 
     # Handle an unknown name.
-    $self->{name} ||= $self->unknown( key => 'name' );
+    $self->{name} ||= $self->unknown( key => 'postgres name' );
 
     # Return the name.
     return $self->{name};
@@ -354,7 +350,7 @@ sub version {
             # Return true.
             return 1;
         };
-        $self->{version} = $self->unknown( key      => 'version number',
+        $self->{version} = $self->unknown( key     => 'postgres version 
number',
                                            callback => $chk_version);
     }
 
@@ -369,7 +365,7 @@ sub version {
 
 Returns the PostgreSQL major version number. App::Info::RDBMS::PostgreSQL
 parses the major version number from the system call C<`pg_config --version`>.
-For example, C<version()> returns "7.1.2", then this method returns "7".
+For example, if C<version()> returns "7.1.2", then this method returns "7".
 
 B<Events:>
 
@@ -407,7 +403,7 @@ sub major_version {
     # Load data.
     $get_version->($self) unless exists $self->{'--version'};
     # Handle an unknown value.
-    $self->{major} = $self->unknown( key      => 'major version number',
+    $self->{major} = $self->unknown( key      => 'postgres major version 
number',
                                      callback => $is_int)
       unless $self->{major};
     return $self->{major};
@@ -455,7 +451,7 @@ sub minor_version {
     # Load data.
     $get_version->($self) unless exists $self->{'--version'};
     # Handle an unknown value.
-    $self->{minor} = $self->unknown( key      => 'minor version number',
+    $self->{minor} = $self->unknown( key      => 'postgres minor version 
number',
                                      callback => $is_int)
       unless defined $self->{minor};
     return $self->{minor};
@@ -503,7 +499,7 @@ sub patch_version {
     # Load data.
     $get_version->($self) unless exists $self->{'--version'};
     # Handle an unknown value.
-    $self->{patch} = $self->unknown( key      => 'patch version number',
+    $self->{patch} = $self->unknown( key      => 'postgres patch version 
number',
                                      callback => $is_int)
       unless defined $self->{patch};
     return $self->{patch};
@@ -558,7 +554,7 @@ my $find_exe = sub  {
         if (my $exe = $u->first_cat_exe([$self->$meth(), $exe], $bin)) {
             # We found it. Confirm.
             $self->{$key} = $self->confirm(
-                key      => $key,
+                key      => "path to $key",
                 prompt   => "Path to $key executable?",
                 value    => $exe,
                 callback => sub { -x },
@@ -567,7 +563,7 @@ my $find_exe = sub  {
         } else {
             # Handle an unknown value.
             $self->{$key} = $self->unknown(
-                key      => $key,
+                key      => "path to $key",
                 prompt   => "Path to $key executable?",
                 callback => sub { -x },
                 error    => 'Not an executable'
@@ -628,7 +624,7 @@ sub bin_dir {
         } else {
             # Handle an unknown value.
             $self->error("Cannot find bin directory");
-            $self->{bin_dir} = $self->unknown( key      => 'bin directory',
+            $self->{bin_dir} = $self->unknown( key      => 'postgres bin dir',
                                                callback => $is_dir)
         }
     }
@@ -674,7 +670,7 @@ sub inc_dir {
         } else {
             # Handle an unknown value.
             $self->error("Cannot find include directory");
-            $self->{inc_dir} = $self->unknown( key      => 'include directory',
+            $self->{inc_dir} = $self->unknown( key      => 'postgres include 
dir',
                                                callback => $is_dir)
         }
     }
@@ -720,7 +716,7 @@ sub lib_dir {
         } else {
             # Handle an unknown value.
             $self->error("Cannot find library directory");
-            $self->{lib_dir} = $self->unknown( key      => 'library directory',
+            $self->{lib_dir} = $self->unknown( key      => 'postgres library 
dir',
                                                callback => $is_dir)
         }
     }
@@ -769,7 +765,7 @@ sub so_lib_dir {
             # Handle an unknown value.
             $self->error("Cannot find shared object library directory");
             $self->{so_lib_dir} =
-              $self->unknown( key      => 'shared object library directory',
+              $self->unknown( key      => 'postgres so directory',
                               callback => $is_dir)
         }
     }
@@ -968,12 +964,8 @@ The available executable methods are:
 
 =item pg_dumpall
 
-=item pg_resetxlog
-
 =item pg_restore
 
-=item pg_upgrade
-
 =item postmaster
 
 =item psql
@@ -1006,12 +998,8 @@ And the corresponding search names methods are:
 
 =item search_pg_dumpall_names
 
-=item search_pg_resetxlog_names
-
 =item search_pg_restore_names
 
-=item search_pg_upgrade_names
-
 =item search_postmaster_names
 
 =item search_psql_names
@@ -1043,14 +1031,19 @@ Path to executable?
 1;
 __END__
 
-=head1 BUGS
+=head1 SUPPORT
+
+This module is stored in an open L<GitHub
+repository|http://github.com/theory/app-info/>. Feel free to fork and
+contribute!
 
-Please send bug reports to <[email protected]> or file them at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info>.
+Please file bug reports via L<GitHub
+Issues|http://github.com/theory/app-info/issues/> or by sending mail to
+L<[email protected]|mailto:[email protected]>.
 
 =head1 AUTHOR
 
-David Wheeler <[email protected]> based on code by Sam Tregar
+David E. Wheeler <[email protected]> based on code by Sam Tregar
 <[email protected]>.
 
 =head1 SEE ALSO
@@ -1067,7 +1060,7 @@ L<http://www.postgresql.org/> is the PostgreSQL home page.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2013, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under 
the
 same terms as Perl itself.
diff --git a/t/lib/App/Info/Request.pm b/t/lib/App/Info/Request.pm
index ecb7a7f..65981eb 100644
--- a/t/lib/App/Info/Request.pm
+++ b/t/lib/App/Info/Request.pm
@@ -42,7 +42,8 @@ to handle the request appropriately.
 
 use strict;
 use vars qw($VERSION);
-$VERSION = '0.45';
+use Carp;
+$VERSION = '0.57';
 
 ##############################################################################
 
@@ -118,6 +119,21 @@ sub new {
 
 =head2 Object Methods
 
+=head3 key
+
+  my $key = $req->key;
+
+Returns the key stored in the App::Info::Request object. The key is used by
+the App::Info subclass to uniquely identify the information it is harvesting,
+such as the path to an executable. It might be used by request handlers,
+for example, to see if an option was passed on the command-line.
+
+=cut
+
+sub key { $_[0]->{key} }
+
+##############################################################################
+
 =head3 message
 
   my $message = $req->message;
@@ -244,14 +260,19 @@ sub value {
 1;
 __END__
 
-=head1 BUGS
+=head1 SUPPORT
+
+This module is stored in an open L<GitHub
+repository|http://github.com/theory/app-info/>. Feel free to fork and
+contribute!
 
-Please send bug reports to <[email protected]> or file them at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info>.
+Please file bug reports via L<GitHub
+Issues|http://github.com/theory/app-info/issues/> or by sending mail to
+L<[email protected]|mailto:[email protected]>.
 
 =head1 AUTHOR
 
-David Wheeler <[email protected]>
+David E. Wheeler <[email protected]>
 
 =head1 SEE ALSO
 
@@ -277,7 +298,7 @@ exemplars for using App::Info::Request objects when 
handling events.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under 
the
 same terms as Perl itself.
diff --git a/t/lib/App/Info/Util.pm b/t/lib/App/Info/Util.pm
index 7e0a1db..f1ffd9e 100644
--- a/t/lib/App/Info/Util.pm
+++ b/t/lib/App/Info/Util.pm
@@ -36,7 +36,7 @@ utility may be considered more general, so feel free to use 
it elsewhere.
 The methods added in addition to the usual File::Spec suspects are designed to
 facilitate locating files and directories on the file system, as well as
 searching those files. The assumption is that, in order to provide useful
-metadata about a given software package, an App::Info subclass must find
+meta data about a given software package, an App::Info subclass must find
 relevant files and directories and parse them with regular expressions. This
 class offers methods that simplify those tasks.
 
@@ -47,13 +47,15 @@ use File::Spec ();
 use Config;
 use vars qw(@ISA $VERSION);
 @ISA = qw(File::Spec);
-$VERSION = '0.45';
+$VERSION = '0.57';
 
-my %path_dems = (MacOS   => qr',',
-                 MSWin32 => qr';',
-                 os2     => qr';',
-                 VMS     => undef,
-                 epoc    => undef);
+my %path_dems = (
+    MacOS   => qr',',
+    MSWin32 => qr';',
+    os2     => qr';',
+    VMS     => undef,
+    epoc    => undef
+);
 
 my $path_dem = exists $path_dems{$^O} ? $path_dems{$^O} : qr':';
 
@@ -72,6 +74,8 @@ to. The constructor here is provided merely as a convenience.
 
 sub new { bless {}, ref $_[0] || $_[0] }
 
+##############################################################################
+
 =head1 OBJECT METHODS
 
 In addition to all of the methods offered by its super class,
@@ -94,33 +98,35 @@ sub first_dir {
     return;
 }
 
+##############################################################################
+
 =head2 first_path
 
   my $path = $ENV{PATH};
   $dir = $util->first_path($path);
 
 Takes the $path string and splits it into a list of directory paths, based on
-the path demarcator on the local file system. Then calls C<first_dir()> to
-return the first directoy in the path list that exists on the local file
-system. The path demarcator is specified for the following file systems:
+the path delimiter on the local file system. Then calls C<first_dir()> to
+return the first directory in the path list that exists on the local file
+system. The path delimiter is specified for the following file systems:
 
 =over 4
 
-=item MacOS: ","
+=item * MacOS: ","
 
-=item MSWin32: ";"
+=item * MSWin32: ";"
 
-=item os2: ";"
+=item * os2: ";"
 
-=item VMS: undef
+=item * VMS: undef
 
 This method always returns undef on VMS. Patches welcome.
 
-=item epoc: undef
+=item * epoc: undef
 
 This method always returns undef on epoch. Patches welcome.
 
-=item Unix: ":"
+=item * Unix: ":"
 
 All other operating systems are assumed to be Unix-based.
 
@@ -133,6 +139,8 @@ sub first_path {
     shift->first_dir(split /$path_dem/, shift)
 }
 
+##############################################################################
+
 =head2 first_file
 
   my $file = $util->first_file(@filelist);
@@ -149,6 +157,8 @@ sub first_file {
     return;
 }
 
+##############################################################################
+
 =head2 first_exe
 
   my $exe = $util->first_exe(@exelist);
@@ -164,6 +174,8 @@ sub first_exe {
     return;
 }
 
+##############################################################################
+
 =head2 first_cat_path
 
   my $file = $util->first_cat_path('ick.txt', @paths);
@@ -220,12 +232,14 @@ sub first_cat_path {
     return;
 }
 
+##############################################################################
+
 =head2 first_cat_dir
 
   my $dir = $util->first_cat_dir('ick.txt', @paths);
   $dir = $util->first_cat_dir(['this.txt', 'that.txt'], @paths);
 
-Funtionally identical to C<first_cat_path()>, except that it returns the
+Functionally identical to C<first_cat_path()>, except that it returns the
 directory path in which the first file was found, rather than the full
 concatenated path. Thus, in the above example, if the file found was
 F</usr/bin/httpd>, while C<first_cat_path()> would return that value,
@@ -245,12 +259,14 @@ sub first_cat_dir {
     return;
 }
 
+##############################################################################
+
 =head2 first_cat_exe
 
-  my $exe = $util->first_cat_exe('ick.txt', @paths);
-  $exe = $util->first_cat_exe(['this.txt', 'that.txt'], @paths);
+  my $exe = $util->first_cat_exe('ick.exe', @paths);
+  $exe = $util->first_cat_exe(['this.exe', 'that.exe'], @paths);
 
-Funtionally identical to C<first_cat_path()>, except that it returns the full
+Functionally identical to C<first_cat_path()>, except that it returns the full
 path to the first executable file found, rather than simply the first file
 found.
 
@@ -268,6 +284,8 @@ sub first_cat_exe {
     return;
 }
 
+##############################################################################
+
 =head2 search_file
 
   my $file = 'foo.txt';
@@ -286,7 +304,7 @@ be grabbed like this:
   my @nums = $util->search_file($file, $regex);
 
 Now C<@nums> will contain the values C<(6, 5, 8)>. Note that in a scalar
-context, the above search would yeild an array reference:
+context, the above search would yield an array reference:
 
   my $regex = qr/Version\s+(\d+)\.(\d+),[^\d]*(\d+)/;
   my $nums = $util->search_file($file, $regex);
@@ -306,7 +324,7 @@ contains a single element: C<("the who?")>.
 
 Note that a regular expression without parentheses -- that is, one that
 doesn't grab values and put them into $1, $2, etc., will never successfully
-match a line in this method. You must include something to parentetically
+match a line in this method. You must include something to parenthetically
 match. If you just want to know the value of what was matched, parenthesize
 the whole thing and if the value returns, you have a match. Also, if you need
 to match patterns across lines, try using multiple regular expressions with
@@ -317,7 +335,7 @@ C<multi_search_file()>, instead.
 sub search_file {
     my ($self, $file, $regex) = @_;
     return unless $file && $regex;
-    open F, "<$file" or Carp::croak "Cannot open $file: $!\n";
+    open F, "<$file" or require Carp && Carp::croak("Cannot open $file: $!\n");
     my @ret;
     while (<F>) {
         # If we find a match, we're done.
@@ -330,17 +348,48 @@ sub search_file {
     return wantarray ? @ret : $#ret <= 0 ? $ret[0] : \@ret;
 }
 
+##############################################################################
+
+=head2 files_in_dir
+
+  my @files = $util->files_in_dir($dir);
+     @files = $util->files_in_dir($dir, $filter);
+  my $files = $util->files_in_dir($dir);
+     $files = $util->files_in_dir($dir, $filter);
+
+Returns an list or array reference of all of the files and directories in the
+file system directory C<$dir>. An optional second argument is a code reference
+that filters the files. The code reference should examine the C<$_> for a file
+name and return true if it's a file that you're interested and false if it's
+not.
+
+=cut
+
+sub files_in_dir {
+    my ($self, $dir, $code) = @_;
+    return unless $dir;
+    local *DIR;
+    opendir DIR, $dir or require Carp && Carp::croak("Cannot open $dir: $!\n");
+    my @files = $code
+        ? grep { $code->() } readdir DIR
+        : readdir DIR;
+    closedir DIR;
+    return wantarray ? @files : \@files;
+}
+
+##############################################################################
+
 =head2 multi_search_file
 
   my @regexen = (qr/(one)/, qr/(two)\s+(three)/);
   my @matches = $util->multi_search_file($file, @regexen);
 
-Like C<search_file()>, this mehod opens C<$file> and parses it for regular
-expresion matches. This method, however, can take a list of regular
+Like C<search_file()>, this method opens C<$file> and parses it for regular
+expression matches. This method, however, can take a list of regular
 expressions to look for, and will return the values found for all of them.
 Regular expressions that match and return multiple values will be returned as
-array referernces, while those that match and return a single value will
-return just that single value.
+array references, while those that match and return a single value will return
+just that single value.
 
 For example, say you are parsing a file with lines like the following:
 
@@ -401,7 +450,7 @@ sub multi_search_file {
     my ($self, $file, @regexen) = @_;
     return unless $file && @regexen;
     my @each = @regexen;
-    open F, "<$file" or Carp::croak "Cannot open $file: $!\n";
+    open F, "<$file" or require Carp && Carp::croak("Cannot open $file: $!\n");
     my %ret;
     while (my $line = <F>) {
         my @splice;
@@ -427,6 +476,8 @@ sub multi_search_file {
     return wantarray ? @ret{@regexen} : \@ret{@regexen};
 }
 
+##############################################################################
+
 =head2 lib_dirs
 
   my @dirs = $util->lib_dirs;
@@ -442,22 +493,29 @@ sub lib_dirs {
     grep { defined and length }
     map { split ' ' }
     grep { defined }
-    $Config{libsdirs},
-    $Config{loclibpth},
+    # Quote Config access to work around
+    # http://bugs.activestate.com/show_bug.cgi?id=89447
+    "$Config{libsdirs}",
+    "$Config{loclibpth}",
     '/sw/lib';
 }
 
 1;
 __END__
 
-=head1 BUGS
+=head1 SUPPORT
+
+This module is stored in an open L<GitHub
+repository|http://github.com/theory/app-info/>. Feel free to fork and
+contribute!
 
-Please send bug reports to <[email protected]> or file them at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info>.
+Please file bug reports via L<GitHub
+Issues|http://github.com/theory/app-info/issues/> or by sending mail to
+L<[email protected]|mailto:[email protected]>.
 
 =head1 AUTHOR
 
-David Wheeler <[email protected]>
+David E. Wheeler <[email protected]>
 
 =head1 SEE ALSO
 
@@ -467,9 +525,9 @@ L<App::Info::RDBMS::PostgreSQL|App::Info::RDBMS::PostgreSQL>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
 
-This module is free software; you can redistribute it and/or modify it under 
the
-same terms as Perl itself.
+This module is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
 
 =cut
-- 
1.8.4

Reply via email to