File Coverage

blib/lib/E2/ClientVersion.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             # E2::ClientVersion
2             # Jose M. Weeks
3             # 05 June 2003
4             #
5             # See bottom for pod documentation.
6              
7             package E2::ClientVersion;
8              
9 1     1   630 use 5.006;
  1         3  
  1         44  
10 1     1   7 use strict;
  1         3  
  1         41  
11 1     1   7 use warnings;
  1         2  
  1         26  
12 1     1   7 use Carp;
  1         2  
  1         74  
13              
14 1     1   7 use E2::Ticker;
  1         2  
  1         28  
15 1     1   1735 use XML::Twig;
  0            
  0            
16              
17             our $VERSION = "0.31";
18             our @ISA = qw(E2::Ticker);
19             our $DEBUG; *DEBUG = *E2::Interface::DEBUG;
20              
21             sub new;
22              
23             sub update;
24              
25             sub clients;
26              
27             sub new {
28             my $arg = shift;
29             my $class = ref( $arg ) || $arg;
30             my $self = $class->SUPER::new();
31              
32             $self->{clients} = {};
33              
34             return bless ($self, $class);
35             }
36              
37              
38             sub clients {
39             my $self = shift or croak "Usage: clients E2CLIENTVERSION";
40             return $self->{clients};
41             }
42              
43             sub update {
44             my $self = shift or croak "Usage: update E2CLIENTVERSION";
45              
46             warn "E2::ClientVersion::Update\n" if $DEBUG > 1;
47              
48             my $handlers = {
49             'client' => sub {
50             (my $a, my $b) = @_;
51             my %client;
52              
53             $client{name} = $b->{att}->{client_class};
54             $client{id} = $b->{att}->{client_id};
55             $client{version} =
56             $b->first_child('version')->text;
57             $client{homepage} =
58             $b->first_child('homepage')->text;
59             $client{download} =
60             $b->first_child('download')->text;
61              
62             my $c = $b->first_child('maintainer');
63             $client{maintainer} = $c->text;
64             $client{maintainer_id} = $c->{att}->{node_id};
65              
66             $self->{clients}->{$client{name}} = \%client;
67             }
68             };
69              
70             $self->{clients} = {};
71              
72             return $self->parse(
73             'clientversions',
74             $handlers,
75             [ 1 ]
76             );
77             }
78              
79             1;
80             __END__