NAME
WebService::UWO::Directory::Student - Module for searching the University of Western Ontario's student directory
VERSION
Version 1.0.2 ($Id: Student.pm 8216 2009-07-25 22:16:50Z FREQUENCY@cpan.org $)
DESCRIPTION
This module provides a Perl interface to the public directory search system which lists current students at the University of Western Ontario. For more information, see the web interface at http://uwo.ca/westerndir/.
SYNOPSIS
Example code:
use WebService::UWO::Directory::Student;
# Create Perl interface to API
my $dir = WebService::UWO::Directory::Student->new;
# Look up a student by name
my $results = $dir->lookup({
first => 'John',
last => 'S'
});
# Go through results
foreach my $stu (@{$results}) {
print 'email: ' . $stu->email . "\n";
}
# Reverse a lookup (use e-mail to find record)
my $reverse = $dir->lookup({
email => 'jsmith@uwo.ca'
});
if (defined $reverse) {
print "Found: $reverse\n";
}
COMPATIBILITY
This module was tested under Perl 5.10.0, using Debian Linux. However, because it's Pure Perl and doesn't do anything too obscure, it should be compatible with any version of Perl that supports its prerequisite modules.
If you encounter any problems on a different version or architecture, please contact the maintainer.
METHODS
WebService::UWO::Directory::Student->new([ \%params ])
Creates a UWO::Directory::Student
search object, which uses a given web page and server. Being that this module is developed to target UWO's in-house system, the defaults should suffice.
The parameters available are:
my $dir = UWO::Directory::Student->new({
url => 'http://uwo.ca/cgi-bin/dsgw/whois2html2',
server => 'localhost',
});
Which instantiates a UWO::Directory::Student
instance using url
as the frontend and server
as the "black-box" backend.
$dir->lookup(\%params)
Uses a WebService::UWO::Directory::Student
search object to locate a given person based on either their name (first
and/or last
) or their e-mail address (email
).
The module uses the following procedure to locate users:
If an e-mail address is provided:
The address is deconstructed into a first initial and the portion of the last name. (According to the regular expression
^(\w)([^\d]+)([\d]*)$
)The partial name is looked up in the directory.
The resulting records are tested against the e-mail address. If the e-mail address matches a given record, an anonymous hash containing user information is returned. The lookup returns a false value (0) upon failure.
If first and/or last names are provided:
The name is searched using the normal interface (using the query
last_name,first_name
) and the results are returned as an array reference. If there are no results, the method returns a false value (0).
Example code:
# Look up "John S" in the student directory
my $results = $dir->lookup({
first => 'John',
last => 'S'
});
# Look up jsmith@uwo.ca
my $reverse = $dir->lookup({
email => 'jsmith@uwo.ca'
});
This method is not guaranteed to return results. Keep in mind that if no results are found, the return code will be 0, so make sure to check return codes before attempting to dereference the expected array/hash.
Record Format
Each returned record will be a hash with the following fields:
last_name,
given_name (which may contain middle names)
email (the registered @uwo.ca e-mail address)
faculty
You may explore this using Data::Dumper
.
UNSUPPORTED API
WebService::UWO::Directory::Student
provides access to some internal methods used to retrieve and process raw data from the directory server. Its behaviour is subject to change and may be finalized later as the need arises.
$dir->_query($query, [ $ua ])
This method performs an HTTP lookup using LWP::UserAgent
and returns a SCALAR reference to the returned page content. A LWP::UserAgent
object may optionally be passed, which is particularly useful if a proxy is required to access the Internet.
Please note that if a LWP::UserAgent
is passed, the User-Agent string will not be modified. In normal operation, this module reports its user agent as 'WebService::UWO::Directory::Student/' . $VERSION
.
WebService::UWO::Directory::Student::_parse($response)
This method processes the HTML content retrieved by _query method and returns an ARRAY reference containing HASH references to the result set. This is most likely only useful for testing purposes.
AUTHOR
Jonathan Yu <frequency@cpan.org>
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc WebService::UWO::Directory::Student
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
http://cpanratings.perl.org/d/WebService-UWO-Directory-Student
Search CPAN
http://search.cpan.org/dist/WebService-UWO-Directory-Student
CPAN Request Tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WebService-UWO-Directory-Student
CPAN Testing Service (Kwalitee Tests)
http://cpants.perl.org/dist/overview/WebService-UWO-Directory-Student
CPAN Testers Platform Compatibility Matrix
http://www.cpantesters.org/show/WebService-UWO-Directory-Student.html
REPOSITORY
You can access the most recent development version of this module at:
http://svn.ali.as/cpan/trunk/WebService-UWO-Directory-Student
If you are a CPAN developer and would like to make modifications to the code base, please contact Adam Kennedy <adamk@cpan.org>, the repository administrator. I only ask that you contact me first to discuss the changes you wish to make to the distribution.
FEEDBACK
Please send relevant comments, rotten tomatoes and suggestions directly to the maintainer noted above.
If you have a bug report or feature request, please file them on the CPAN Request Tracker at http://rt.cpan.org. If you are able to submit your bug report in the form of failing unit tests, you are strongly encouraged to do so.
SEE ALSO
http://uwo.ca/westerndir/index-student.html
CAVEATS
KNOWN BUGS
There are no known bugs as of this release.
LIMITATIONS
This module is only able to access partial student records since students must give consent for their contact information to be published on the web. For details, see http://uwo.ca/westerndir/index-student.html.
Some students change their name (for example, a marriage), while retainining the same email address. This means their email addresses cannot be effectively reverse-searched.
This module has not been very thoroughly tested for memory consumption. It does a lot of copying that should be optimized, however, it is probably not necessary for most uses.
LICENSE
Copyleft 2006-2009 by Jonathan Yu <frequency@cpan.org>. All rights reversed.
I, the copyright holder of this package, hereby release the entire contents therein into the public domain. This applies worldwide, to the extent that it is permissible by law.
In case this is not legally possible, I grant any entity the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
The full details of this can be found in the LICENSE file included in this package.
DISCLAIMER OF WARRANTY
The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.