XMPP/Ext/Disco/Items.pm

filter: Statementstmt 22.5% 7 / 31 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 22.2% 2 / 9 Podpod 71.4% 5 / 7 totaltotal 25.9% 14 / 54 CC 5 SCAR 16.8
CC
5
Cov
19%
init
12.0
new
6.0
debug_dump
6.0
CRAP 5.4
« XMPP/Namespaces.pm ↑ Summary XMPP/Error/IQAuth.pm »
1 package AnyEvent::XMPP::Ext::Disco::Items;
2 1 ▶use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 AnyEvent::XMPP::Ext::Disco::Items - Service discovery items
8  
9 =head1 SYNOPSIS
10  
11 =head1 DESCRIPTION
12  
13 This class represents the result of a disco items request
14 sent by a C<AnyEvent::XMPP::Ext::Disco> handler.
15  
16 =head1 METHODS
17  
18 =over 4
19  
20 =cut
21  
22 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my $this = shift;
24 0 ▶ my $class = ref($this) || $this;
Condition0%0/3
ref $this || $this
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table0%0/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
25 0 my $self = bless { @_ }, $class;
26 0 $self->init;
27 0 $self
28 }
29  
30 =item B<xml_node ()>
31  
32 Returns the L<AnyEvent::XMPP::Node> object of the IQ query.
33  
34 =cut
35  
36 0 ▶sub xml_node {
Subroutine xml_node: not called CC=1 SCAR=6.9
Pod documented
37 0 my ($self) = @_;
38 $self->{xmlnode}
39 0 }
40  
41 0 ▶sub init {
Subroutine init: not called CC=3 SCAR=24.8
Pod undocumented
42 0 my ($self) = @_;
43 0 my $node = $self->{xmlnode};
44 0 ▶ return unless $node;
Branch: 1 branch
BranchTrueFalseTotal
unless $node 0 0 0
45  
46 0 my (@items) = $node->find_all ([qw/disco_items item/]);
47 0 for (@items) {
48 0 push @{$self->{items}}, {
49 jid => $_->attr ('jid'),
50 name => $_->attr ('name'),
51 node => $_->attr ('node'),
52 xml_node => $_,
53 };
54 }
55 }
56  
57 =item B<jid ()>
58  
59 Returns the JID these items belong to.
60  
61 =cut
62  
63 0 ▶sub jid { $_[0]->{jid} }
Subroutine jid: not called CC=1 SCAR=6.9
Pod documented
64  
65 =item B<node ()>
66  
67 Returns the node these items belong to (may be undef).
68  
69 =cut
70  
71 0 ▶sub node { $_[0]->{node} }
Subroutine node: not called CC=1 SCAR=6.9
Pod documented
72  
73 =item B<items ()>
74  
75 Returns a list of hashreferences which contain following keys:
76  
77 jid, name, node and xml_node
78  
79 C<jid> contains the JID of the item.
80 C<name> contains the name of the item and might be undef.
81 C<node> contains the node id of the item and might be undef.
82 C<xml_node> contains the L<AnyEvent::XMPP::Node> object of the item
83 for further analyses.
84  
85 =cut
86  
87 0 ▶sub items {
Subroutine items: not called CC=1 SCAR=6.9
Pod documented
88 0 my ($self) = @_;
89 0 @{$self->{items}}
90 }
91  
92 =item B<debug_dump ()>
93  
94 Prints these items to stdout for debugging.
95  
96 =cut
97  
98 0 ▶sub debug_dump {
Subroutine debug_dump: not called CC=2 SCAR=17.9
Pod documented
99 0 my ($self) = @_;
100 0 printf "ITEMS FOR %s (%s):\n", $self->jid, $self->node;
101 0 for ($self->items) {
102 printf " - %-40s (%30s): %s\n", $_->{jid}, $_->{node}, $_->{name}
103 0 }
104 0 print "END ITEMS\n";
105 }
106  
107 =back
108  
109 =head1 AUTHOR
110  
111 Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
112  
113 =head1 COPYRIGHT & LICENSE
114  
115 Copyright 2007, 2008 Robin Redeker, all rights reserved.
116  
117 This program is free software; you can redistribute it and/or modify it
118 under the same terms as Perl itself.
119  
120 =cut
121  
122 1 1;
« XMPP/Namespaces.pm ↑ Summary XMPP/Error/IQAuth.pm »