FlashRemoting/Action/Gateway.pm

filter: Statementstmt 32.5% 13 / 40 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 31.5% 18 / 57 CC 6 SCAR 32.4
CC
6
Cov
27%
execute
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 25.6
↑ Summary FlashRemoting.pm »
1 package Catalyst::Controller::FlashRemoting::Action::Gateway;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw/Catalyst::Action/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Data::AMF::Packet;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub execute {
Subroutine execute: not called CC=6 SCAR=37.4
Pod documented
9 0 my $self = shift;
10 0 my ($controller, $c, @args) = @_;
11  
12 0 ▶ if ($c->req->content_type eq 'application/x-amf' and my $body = $c->req->body) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->req->content_type eq 'application/x-amf' and my $body = $c->req->body) { } 0 0 0
Condition0%0/3
$c->req->content_type eq "application/x-amf" and my $body = $c->req->body
!ll&&!rl&&r
000
MC/DC0%0/2
$c->req->content_type eq "application/x-amf" and my $body = $c->req->body
$c->req->content_type eq "application/x-amf" my $body = $c->req->body
Truth table0%0/3
A and B
A= $c->req->content_type eq "application/x-amf"B= my $body = $c->req->body
ABresult
0X0
100
111
13 0 my $data = do { local $/; <$body> };
14  
15 0 my $request = Data::AMF::Packet->deserialize($data);
16  
17 0 my @results;
18 0 for my $message (@{ $request->messages }) {
19 0 my $method = $controller->_amf_method->{ $message->target_uri };
20  
21 0 ▶ if ($method) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method) { } 0 0 0
22 0 my $res;
23 0 eval {
24 0 $res = $method->($controller, $c, $message->value);
25 };
26 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
27 0 (my $res = $@) =~ s/ at.*?$//;
28 0 push @results, $message->error($res);
29 }
30 else {
31 0 push @results, $message->result($res);
32 }
33 }
34 else {
35 0 $c->log->error(qq{method for "@{[ $message->target_uri ]}" does not exist});
36 }
37 }
38  
39 0 my $response = Data::AMF::Packet->new(
40 version => $request->version,
41 headers => [],
42 messages => \@results,
43 );
44  
45 0 $c->res->content_type('application/x-amf');
46 0 $c->res->body( $response->serialize );
47 }
48 else {
49 0 $c->res->status(500);
50 0 $c->res->body('');
51 }
52  
53 0 $self->NEXT::execute(@_);
54 }
55  
56 =head1 NAME
57  
58 Catalyst::Controller::FlashRemoting::Action::Gateway - Action class for AMF Method
59  
60 =head1 DESCRIPTION
61  
62 See L<Catalyst::Controller::FlashRemoting>.
63  
64 =head1 METHOD
65  
66 =head2 execute
67  
68 =head1 AUTHOR
69  
70 Daisuke Murase <typester@cpan.org>
71  
72 =head1 COPYRIGHT
73  
74 This program is free software; you can redistribute
75 it and/or modify it under the same terms as Perl itself.
76  
77 The full text of the license can be found in the
78 LICENSE file included with this module.
79  
80 =cut
81  
82 1 1;
83  
↑ Summary FlashRemoting.pm »