Moose/Connection/HTTP.pm

filter: Statementstmt 70.2% 33 / 47 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 69.2% 9 / 13 Podpod 0.0% 0 / 3 totaltotal 66.6% 42 / 63 CC 1 SCAR 2.1
CC
1
Cov
70%
_build_ua
2.0
Read
2.0
Write
2.0
CRAP 1.2
« Moose/Instrument/SCPI/Unit.pm ↑ Summary Moose/Instrument/SCPI/Display/Window.pm »
1 package Lab::Moose::Connection::HTTP;
2 1 $Lab::Moose::Connection::HTTP::VERSION = '3.931';
3 #ABSTRACT: Connection with Http requests
4  
5 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moose::Util::TypeConstraints qw(enum);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Lab::Moose::Instrument qw/timeout_param read_length_param/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 1 has ip => (
21 is => 'ro',
22 isa => 'Str',
23 required => 1,
24 reader => 'get_ip',
25 );
26  
27 1 has port => (
28 is => 'ro',
29 isa => 'Lab::Moose::PosNum',
30 required => 1,
31 reader => 'get_port',
32 );
33  
34 1 has ua => (
35 is => 'ro',
36 isa => 'Any',
37 builder => '_build_ua',
38 );
39  
40 0 ▶sub _build_ua {
Subroutine _build_ua: not called CC=1 SCAR=6.9
41 0 return LWP::UserAgent->new();
42 }
43  
44 0 ▶sub Read {
Subroutine Read: not called CC=1 SCAR=6.9
Pod undocumented
45 0 my ( $self, %args ) = validated_hash(
46 \@_,
47 endpoint => { isa => 'Str' },
48 );
49 0 my $endpoint = $args{'endpoint'};
50  
51 0 my $url = "http://". $self->get_ip(). ":" . $self->get_port() . $endpoint;
52 0 my $req = HTTP::Request->new( 'GET', $url );
53  
54 0 return $self->ua->request( $req );
55 }
56  
57 0 ▶sub Write {
Subroutine Write: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my ( $self, %args ) = validated_hash(
59 \@_,
60 endpoint => { isa => 'Str' },
61 body => { isa => 'Str' },
62 );
63 0 my $endpoint = $args{'endpoint'};
64 0 my $body = $args{'body'};
65  
66 0 my $url = "http://". $self->get_ip(). ":" . $self->get_port() . $endpoint;
67 0 my $req = HTTP::Request->new( 'POST', $url);
68 0 $req->header( 'Content-Type' => 'application/json' );
69 0 $req->content( $body );
70  
71 0 return $self->ua->request( $req );
72 }
73  
74 0 ▶sub Clear {
Subroutine Clear: not called CC=1 SCAR=0.0
Pod undocumented
75  
76 }
77  
78 1 with 'Lab::Moose::Connection';
79  
80 1 __PACKAGE__->meta->make_immutable;
81  
82 1 1;
83  
84 __END__
« Moose/Instrument/SCPI/Unit.pm ↑ Summary Moose/Instrument/SCPI/Display/Window.pm »