WWW::OPG - Perl interface to Ontario Power Generation's site
Version 1.005 ($Id: OPG.pm 11016 2010-01-16 06:11:43Z FREQUENCY@cpan.org $)
use WWW::OPG; my $opg = WWW::OPG->new(); eval { $opg->poll(); }; print "Currently generating ", $opg->power, "MW of electricity\n";
This module provides a Perl interface to information published on Ontario Power Generation's web site at http://www.opg.com. This module provides very quick and low-bandwidth queries using the special machine-readable file proffered by OPG; see http://www.opg.com/megafile.txt.
This module was tested under Perl 5.10.1, 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.
WWW::OPG->new( \%params )
Initialize a WWW::OPG object, setting up the user agent and preparing for a transaction. Note that you can pass a LWP::UserAgent object or a subclass thereof, which can include your proxy or UserAgent settings.
WWW::OPG
Example code:
my $opg = WWW::OPG->new(); # or, with some parameters: my $opg = WWW::OPG->new({ useragent => LWP::UserAgent->new() });
This method will return an appropriate WWW::OPG object or throw an exception on error.
$opg->poll()
Update data in the WWW::OPG object, $obj, by connecting to the OPG site and scraping data. The data can then be extracted using the other methods available in this class.
$obj
$opg->poll();
This method will return a true value if an update has been performed, a false value if the data is unchanged since the last update, or throw an exception on error.
$opg->power()
Returns the amount of power being generated by Ontario Power Generation (OPG) plants, in MegaWatts (MW).
$opg->poll(); print "Currently generating ", $opg->power, " MW for Ontario\n";
Note that this value may be undefined if the server has not yet been polled, or if there was a failure polling.
$opg->last_updated()
Returns the date and time that the data was last updated (as defined by the remote OPG web server), given as a DateTime object.
$opg->poll(); print "Last updated ", $opg->last_updated, "\n";
Jonathan Yu <jawnsy@cpan.org>
Your name here ;-)
Thanks to the kind folks at OPG and in particular someone I know only as "Rose" <webmaster@opg.com> for providing me with an API in the form of a small text file which provides the same data as that scraped from the web page itself. This cuts down significantly on bandwidth costs and the time it takes to check the data.
You can find documentation for this module with the perldoc command.
perldoc WWW::OPG
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/WWW-OPG
CPAN Ratings
http://cpanratings.perl.org/d/WWW-OPG
Search CPAN
http://search.cpan.org/dist/WWW-OPG
CPAN Request Tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-OPG
CPAN Testing Service (Kwalitee Tests)
http://cpants.perl.org/dist/overview/WWW-OPG
CPAN Testers Platform Compatibility Matrix
http://www.cpantesters.org/show/WWW-OPG.html
You can access the most recent development version of this module at:
http://svn.ali.as/cpan/trunk/WWW-OPG
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.
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.
http://www.opg.com, the Ontario Power Generation web site.
There are no known bugs as of this release.
The only data currently easily available from the Ontario Power Generation web site is the data for power currently being generated for the province of Ontario, in MegaWatts (MW). This data seems to be updated every five minutes.
File stmt bran cond sub pod total ----------------------- ------ ------ ------ ------ ------ ------ lib/WWW/OPG.pm 92.9 71.4 66.7 100.0 100.0 87.1
In a perfect world, I could just say that this package and all of the code it contains is Public Domain. It's a bit more complicated than that; you'll have to read the included LICENSE file to get the full details.
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.
To install WWW::OPG, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::OPG
CPAN shell
perl -MCPAN -e shell install WWW::OPG
For more information on module installation, please visit the detailed CPAN module installation guide.