E2-Interface
view release on metacpan or search on metacpan
ClientVersion.pm view on Meta::CPAN
# E2::ClientVersion
# Jose M. Weeks <jose@joseweeks.com>
# 05 June 2003
#
# See bottom for pod documentation.
package E2::ClientVersion;
use 5.006;
use strict;
use warnings;
use Carp;
use E2::Ticker;
use XML::Twig;
our $VERSION = "0.31";
our @ISA = qw(E2::Ticker);
our $DEBUG; *DEBUG = *E2::Interface::DEBUG;
sub new;
sub update;
sub clients;
sub new {
my $arg = shift;
my $class = ref( $arg ) || $arg;
my $self = $class->SUPER::new();
$self->{clients} = {};
return bless ($self, $class);
}
sub clients {
my $self = shift or croak "Usage: clients E2CLIENTVERSION";
return $self->{clients};
}
sub update {
my $self = shift or croak "Usage: update E2CLIENTVERSION";
warn "E2::ClientVersion::Update\n" if $DEBUG > 1;
my $handlers = {
'client' => sub {
(my $a, my $b) = @_;
my %client;
$client{name} = $b->{att}->{client_class};
$client{id} = $b->{att}->{client_id};
$client{version} =
$b->first_child('version')->text;
$client{homepage} =
$b->first_child('homepage')->text;
$client{download} =
$b->first_child('download')->text;
my $c = $b->first_child('maintainer');
$client{maintainer} = $c->text;
$client{maintainer_id} = $c->{att}->{node_id};
$self->{clients}->{$client{name}} = \%client;
}
};
$self->{clients} = {};
return $self->parse(
'clientversions',
$handlers,
[ 1 ]
);
}
1;
__END__
=head1 NAME
E2::ClientVersion - Load client version information from everything2.com
=head1 SYNOPSIS
use E2::ClientVersion;
my $client = new E2::ClientVersion;
$client->update;
my $c = $client->clients;
# Print the current and available version of e2interface
my $ver = $client->version; # See E2::Interface;
my $name = $client->client_name; # See E2::interface;
print "We are using $name/$ver.";
print "\nThe newest available version of $name is ";
( run in 1.715 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )