File Coverage

ex/MyAppCode.pm
Criterion Covered Total %
statement 17 17 100.0
branch 3 4 75.0
condition 2 2 100.0
subroutine 6 6 100.0
pod 3 3 100.0
total 31 32 96.8


line stmt bran cond sub pod time code
1             package MyAppCode;
2 21     21   2897 use warnings;
  21         163  
  21         753  
3 21     21   96 use strict;
  21         46  
  21         2561  
4              
5             our $VERSION = '0.000_01';
6              
7             =head1 NAME
8              
9             MyAppCode - Demo code for the service...
10              
11             =head1 DESCRIPTION
12              
13             =head2 do_ping()
14              
15             returns 'pong'
16              
17             =for xmlrpc ping do_ping
18              
19             =for jsonrpc ping do_ping
20              
21             =for restrpc ping do_ping
22              
23             =cut
24              
25 5     5 1 21 sub do_ping { return 'pong' }
26              
27             =head2 do_version()
28              
29             Returns a struct:
30              
31             {software => 2.000_00}
32              
33             =for xmlrpc version do_version
34              
35             =for jsonrpc version do_version
36              
37             =for restrpc version do_version
38              
39             =cut
40              
41             sub do_version {
42 3     3 1 12 return {software => $VERSION};
43             }
44              
45             =head2 do_methodlist
46              
47             Returns a list of all known methods.
48              
49             =for xmlrpc methodList do_methodlist
50              
51             =for jsonrpc method.list do_methodlist
52              
53             =for restrpc method_list do_methodlist
54              
55             =cut
56              
57             sub do_methodlist {
58 6 100   6 1 25 my %args = ref($_[1]) eq 'HASH' ? %{$_[1]} : ();
  4         17  
59 6         28 while (my ($k, $v) = each %args) {
60 4 50       25 delete $args{$k} if $k ne 'plugin';
61             }
62              
63 21     21   684 use Dancer2::RPCPlugin::DispatchMethodList;
  21         35  
  21         1192  
64 6         41 my $dispatch = Dancer2::RPCPlugin::DispatchMethodList->new;
65 6   100     36 return $dispatch->list_methods($args{plugin}//'any');
66             }
67              
68             __END__