File Coverage

blib/lib/Lim/Agent/Server.pm
Criterion Covered Total %
statement 14 54 25.9
branch 0 16 0.0
condition n/a
subroutine 5 9 55.5
pod 5 5 100.0
total 24 84 28.5


line stmt bran cond sub pod time code
1             package Lim::Agent::Server;
2              
3 3     3   5075 use common::sense;
  3         8  
  3         36  
4              
5 3     3   178 use Lim ();
  3         9  
  3         57  
6 3     3   1563 use Lim::Plugins ();
  3         10  
  3         92  
7              
8 3     3   36 use base qw(Lim::Component::Server);
  3         11  
  3         2833  
9              
10             =encoding utf8
11              
12             =head1 NAME
13              
14             ...
15              
16             =head1 VERSION
17              
18             See L for version.
19              
20             =cut
21              
22             our $VERSION = $Lim::VERSION;
23              
24             =head1 SYNOPSIS
25              
26             ...
27              
28             =head1 SUBROUTINES/METHODS
29              
30             =head2 ReadVersion
31              
32             =cut
33              
34             sub ReadVersion {
35 2     2 1 8 my ($self, $cb) = @_;
36            
37 2         35 $self->Successful($cb, { version => $VERSION });
38             }
39              
40             =head2 ReadPlugins
41              
42             =cut
43              
44             sub ReadPlugins {
45 0     0 1   my ($self, $cb) = @_;
46            
47 0           $self->Successful($cb, { plugin => [ {
48             name => Lim::Agent->Name,
49             description => Lim::Agent->Description,
50             module => 'Lim::Agent',
51             version => $VERSION,
52             loaded => 1 },
53             Lim::Plugins->instance->All
54             ] });
55             }
56              
57             =head2 ReadPlugin
58              
59             =cut
60              
61             sub ReadPlugin {
62 0     0 1   my ($self, $cb, $q) = @_;
63 0           my @plugins = ( Lim::Plugins->instance->All );
64 0           my $result = {
65             plugin => [ {
66             name => Lim::Agent->Name,
67             description => Lim::Agent->Description,
68             module => 'Lim::Agent',
69             version => $VERSION,
70             loaded => 1
71             } ]
72             };
73              
74 0 0         foreach my $plugin (ref($q->{plugin}) eq 'ARRAY' ? @{$q->{plugin}} : $q->{plugin}) {
  0            
75 0           foreach my $loaded (@plugins) {
76 0 0         if (lc($loaded->{name}) eq $plugin->{name}) {
77 0           push(@{$result->{plugin}}, $loaded);
  0            
78             }
79             }
80             }
81 0           $self->Successful($cb, $result);
82             }
83              
84             =head2 ReadPluginVersion
85              
86             =cut
87              
88             sub ReadPluginVersion {
89 0     0 1   my ($self, $cb, $q) = @_;
90 0           my @plugins = ( Lim::Plugins->instance->All );
91 0           my $result = {};
92              
93 0 0         foreach my $plugin (ref($q->{plugin}) eq 'ARRAY' ? @{$q->{plugin}} : $q->{plugin}) {
  0            
94 0 0         if ($plugin->{name} eq Lim::Agent->Name) {
95 0           push(@{$result->{plugin}}, {
  0            
96             name => Lim::Agent->Name,
97             version => $VERSION
98             });
99 0           next;
100             }
101 0           foreach my $loaded (@plugins) {
102 0 0         if (lc($loaded->{name}) eq $plugin->{name}) {
103 0           push(@{$result->{plugin}}, {
  0            
104             name => $loaded->{name},
105             version => $loaded->{version}
106             });
107             }
108             }
109             }
110 0           $self->Successful($cb, $result);
111             }
112              
113             =head2 ReadPluginLoaded
114              
115             =cut
116              
117             sub ReadPluginLoaded {
118 0     0 1   my ($self, $cb, $q) = @_;
119 0           my @plugins = ( Lim::Plugins->instance->All );
120 0           my $result = {};
121              
122 0 0         foreach my $plugin (ref($q->{plugin}) eq 'ARRAY' ? @{$q->{plugin}} : $q->{plugin}) {
  0            
123 0 0         if ($plugin->{name} eq Lim::Agent->Name) {
124 0           push(@{$result->{plugin}}, {
  0            
125             name => Lim::Agent->Name,
126             loaded => 1
127             });
128 0           next;
129             }
130 0           foreach my $loaded (@plugins) {
131 0 0         if (lc($loaded->{name}) eq $plugin->{name}) {
132 0           push(@{$result->{plugin}}, {
  0            
133             name => $loaded->{name},
134             loaded => $loaded->{loaded}
135             });
136             }
137             }
138             }
139 0           $self->Successful($cb, $result);
140             }
141              
142             =head1 AUTHOR
143              
144             Jerry Lundström, C<< >>
145              
146             =head1 BUGS
147              
148             Please report any bugs or feature requests to L.
149              
150             =head1 SUPPORT
151              
152             You can find documentation for this module with the perldoc command.
153              
154             perldoc Lim
155              
156             You can also look for information at:
157              
158             =over 4
159              
160             =item * Lim issue tracker (report bugs here)
161              
162             L
163              
164             =back
165              
166             =head1 ACKNOWLEDGEMENTS
167              
168             =head1 LICENSE AND COPYRIGHT
169              
170             Copyright 2012-2013 Jerry Lundström.
171              
172             This program is free software; you can redistribute it and/or modify it
173             under the terms of either: the GNU General Public License as published
174             by the Free Software Foundation; or the Artistic License.
175              
176             See http://dev.perl.org/licenses/ for more information.
177              
178              
179             =cut
180              
181             1; # End of Lim::Agent