blib/lib/Froody/Pod.pm

filter: Statementstmt 19.1% 13 / 68 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 44.4% 4 / 9 Podpod 100% 1 / 1 totaltotal 20.2% 18 / 89 CC 9 SCAR 23.0
CC
9
Cov
17%
_print_arguments
20.0
run
12.0
_print_errors
12.0
CRAP 10.0
« blib/lib/Froody/Walker.pm ↑ Summary blib/lib/Froody/Request/Apache.pm »
1 package Froody::Pod;
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Froody::Dispatch;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Froody::Pod
11  
12 =head1 SYNOPSIS
13  
14 use Froody::Pod;
15 Froody::Pod->run( 'My::Froody::API' );
16  
17 =head1 DESCRIPTION
18  
19 Create a POD file for L<Froody> services.
20  
21 =head2 Methods
22  
23 =over
24  
25 =item run( api )
26  
27 Passed the name of a subclass of L<Froody::API>, this documents the API
28 to STDOUT as a POD file.
29  
30 =cut
31  
32 0 ▶sub run {
Subroutine run: not called CC=3 SCAR=24.8
Pod documented
33 0 my ($class, @args) = @_;
34  
35 0 my ($client,$args) = Froody::Dispatch->cli_config(@args);
36 0 my @methods = $client->get_methods();
37
38 0 print "=head1 NAME\n\n";
39 0 ▶ my $filters = $args->{filters} || 'all available methods';
Condition0%0/2
$args->{'filters'} || 'all available methods'
l!l
00
MC/DC0%0/1
$args->{'filters'} || 'all available methods'
$args->{'filters'}
Truth table0%0/2
A
A= $args->{'filters'}
Aresult
11
00
40 0 print "\n\n";
41
42 0 print "=head1 DESCRIPTION\n\n";
43 0 print "Froody API documentation\n\n";
44
45 0 print "=head2 Methods\n\n";
46
47 0 print "=over\n\n";
48
49 0 for my $method(sort {$a->full_name() cmp $b->full_name()} @methods) {
50 0 _print_method($method);
51 }
52 0 print "=back\n\n";
53 }
54  
55  
56 0 ▶sub _print_method {
Subroutine _print_method: not called CC=1 SCAR=6.9
57 0 my $method = shift;
58
59 0 print "=item B<" . $method->full_name() . ">\n\n";
60 0 print " " .$method->description . "\n\n";
61
62 0 _print_arguments($method);
63 0 _print_errors($method);
64 0 _print_response($method);
65 }
66  
67 0 ▶sub _print_arguments {
Subroutine _print_arguments: not called CC=4 SCAR=30.0
68 0 my $method = shift;
69 0 print "=over 2\n\n";
70 0 print "=head3 Arguments\n\n";
71 0 ▶ if (my %arguments = %{$method->arguments()}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(%arguments) = %{$method->arguments;}) { } 0 0 0
72 0 for my $name (keys(%arguments)) {
73 0 my $argument = $arguments{$name};
74 0 print "=item $name\n\n";
75 0 print "Type: " . join(",",@{$argument->{type}}) . "\n\n";
76 0 print "Description: $argument->{doc}\n\n";
77 0 print "Required: ";
78 0 ▶ print $argument->{optional} ? "optional\n\n" : "required\n\n";
Branch: 1 branch
BranchTrueFalseTotal
$argument->{'optional'} ? : 0 0 0
79 }
80 } else {
81 0 print "None\n\n";
82 }
83 0 print "=back\n\n";
84 }
85  
86 0 ▶sub _print_errors {
Subroutine _print_errors: not called CC=3 SCAR=24.8
87 0 my $method = shift;
88 0 print "=over 2\n\n";
89 0 print "=head3 Errors\n\n";
90 0 ▶ if (my %errors = %{$method->errors()}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(%errors) = %{$method->errors;}) { } 0 0 0
91 0 for my $code (keys(%errors)) {
92 0 my $error = $errors{$code};
93 0 print "=item $code\n\n";
94 0 print "$error->{description}\n\n";
95 }
96 } else {
97 0 print "None\n\n";
98 }
99 0 print "=back\n\n";
100 }
101  
102 0 ▶sub _print_response {
Subroutine _print_response: not called CC=2 SCAR=17.9
103 0 my $method = shift;
104 0 print "=over 2\n\n";
105 0 print "=head3 Response\n\n";
106 0 ▶ if (my $response = $method->example_response()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $response = $method->example_response) { } 0 0 0
107 0 my $xml = $response->render(1);
108 0 $xml =~ s|\n|\n |g;
109 0 print " $xml \n\n";
110 # print Dumper($response->xml());
111 } else {
112 0 print "Empty response\n\n";
113 }
114 0 print "=back\n\n";
115 }
116  
117 =back
118  
119 =head1 BUGS
120  
121 None known.
122  
123 Please report any bugs you find via the CPAN RT system.
124 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody>
125  
126 =head1 AUTHOR
127  
128 Copyright Fotango 2005. All rights reserved.
129  
130 Please see the main L<Froody> documentation for details of who has worked
131 on this project.
132  
133 This module is free software; you can redistribute it and/or modify it under
134 the same terms as Perl itself.
135  
136 =head1 SEE ALSO
137  
138 L<Froody>
139  
140 =cut
141  
142 2 1;
143  
« blib/lib/Froody/Walker.pm ↑ Summary blib/lib/Froody/Request/Apache.pm »