blib/lib/Net/Azure/EventHubs.pm

filter: Statementstmt 100% 70 / 70 Branchbran 100% 8 / 8 Conditioncond 100% 14 / 14 MC/DCmcdc 100% 9 / 9 Subroutinesub 100% 17 / 17 Podpod 100% 2 / 2 totaltotal 100% 120 / 120 SCAR 23.0
CC
10
Cov
100%
_req
6.0
new
4.0
_uri
2.0
CRAP 10.0
↑ Summary blib/lib/Net/Azure/EventHubs/Response.pm »
1 package Net::Azure::EventHubs;
2 5 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Net::Azure::EventHubs::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Net::Azure::Authorization::SAS;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 use Class::Accessor::Lite (
15 5 new => 0,
16 ro => [qw[
17 agent
18 timeout
19 serializer
20 api_version
21 authorizer
22 ]],
23 5 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 5 our $VERSION = "0.08";
26 5 our $DEFAULT_API_VERSION = '2014-01';
27 5 our $DEFAULT_TIMEOUT = 60;
28  
29 sub new {
30 9 ▶ my ($class, %param) = @_;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
31  
32 9 $param{agent} = LWP::UserAgent->new(agent => sprintf('%s/%s', $class, $VERSION));
33 9 $param{serializer} = JSON->new->utf8(1);
34 9 ▶ $param{api_version} ||= $DEFAULT_API_VERSION;
Condition100%3/3
$param{"api_version"} ||= $Net::Azure::EventHubs::DEFAULT_API_VERSION
l!l&&r!l&&!r
162
MC/DC100%2/2
$param{"api_version"} ||= $Net::Azure::EventHubs::DEFAULT_API_VERSION
$param{"api_version"} $Net::Azure::EventHubs::DEFAULT_API_VERSION
Truth table100%3/3
A ||= B
A= $param{"api_version"}B= $Net::Azure::EventHubs::DEFAULT_API_VERSION
ABresult
1X1
011
000
35 9 ▶ $param{timeout} ||= $DEFAULT_TIMEOUT;
Condition100%3/3
$param{"timeout"} ||= $Net::Azure::EventHubs::DEFAULT_TIMEOUT
l!l&&r!l&&!r
162
MC/DC100%2/2
$param{"timeout"} ||= $Net::Azure::EventHubs::DEFAULT_TIMEOUT
$param{"timeout"} $Net::Azure::EventHubs::DEFAULT_TIMEOUT
Truth table100%3/3
A ||= B
A= $param{"timeout"}B= $Net::Azure::EventHubs::DEFAULT_TIMEOUT
ABresult
1X1
011
000
36  
37 9 ▶ if (!defined $param{authorizer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $param{"authorizer"}) 8 1 9
38 my $authorizer = try {
39 Net::Azure::Authorization::SAS->new(connection_string => $param{connection_string})
40 8 ▶ } catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 1 ▶ croak $_;
Subroutine __ANON__: called CC=1 SCAR=0.0
42 8 };
43 7 $param{authorizer} = $authorizer;
44 }
45  
46 8 bless {%param}, $class;
47 }
48  
49 sub _uri {
50 7 ▶ my ($self, $path, %params) = @_;
Subroutine _uri: called CC=2 SCAR=6.9
51 7 ▶ $path ||= '/';
Condition100%2/2
$path ||= "/"
l!l
61
MC/DC100%1/1
$path ||= "/"
$path
Truth table100%2/2
A
A= $path
Aresult
11
00
52 7 my $uri = URI->new($self->authorizer->endpoint);
53 7 $uri->scheme('https');
54 7 $uri->path($path);
55 7 $uri->query_form(%params);
56 7 $uri;
57 }
58  
59 sub _req {
60 7 ▶ my ($self, $path, $payload, %params) = @_;
Subroutine _req: called CC=6 SCAR=17.9
61 7 ▶ croak 'path is reuired' if !defined $path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 1 6 7
62 6 ▶ croak 'payload is required' if !defined $payload;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $payload 1 5 6
63 5 ▶ croak 'payload is not hashref' if ref($payload) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "HASH" 1 4 5
64 4 ▶ $params{timeout} ||= $self->timeout;
Condition100%3/3
$params{"timeout"} ||= $self->timeout
l!l&&r!l&&!r
121
MC/DC100%2/2
$params{"timeout"} ||= $self->timeout
$params{"timeout"} $self->timeout
Truth table100%3/3
A ||= B
A= $params{"timeout"}B= $self->timeout
ABresult
1X1
011
000
65 4 ▶ $params{api_version} ||= $self->api_version;
Condition100%3/3
$params{"api_version"} ||= $self->api_version
l!l&&r!l&&!r
121
MC/DC100%2/2
$params{"api_version"} ||= $self->api_version
$params{"api_version"} $self->api_version
Truth table100%3/3
A ||= B
A= $params{"api_version"}B= $self->api_version
ABresult
1X1
011
000
66 4 my $uri = $self->_uri($path, %params);
67 4 my $auth = $self->authorizer->token($uri->as_string);
68 4 my $data = $self->serializer->encode($payload);
69 4 my $req = Net::Azure::EventHubs::Request->new(
70 POST => $uri->as_string,
71 [
72 'Authorization' => $auth,
73 'Content-Type' => 'application/atom+xml;type=entry;charset=utf-8',
74 ],
75 $data,
76 );
77 4 $req->agent($self->agent);
78 4 $req;
79 }
80  
81 sub message {
82 1 ▶ my ($self, $payload) = @_;
Subroutine message: called CC=1 SCAR=0.0
Pod documented
83 1 my $path = sprintf "/%s/messages", $self->authorizer->{entity_path};
84 1 my $req = $self->_req($path => $payload);
85 1 $req;
86 }
87  
88  
89 5 1;
90 __END__
↑ Summary blib/lib/Net/Azure/EventHubs/Response.pm »