File Coverage

blib/lib/Lab/Moose/Connection/WWW.pm
Criterion Covered Total %
statement 23 31 74.1
branch n/a
condition n/a
subroutine 8 10 80.0
pod 0 2 0.0
total 31 43 72.0


line stmt bran cond sub pod time code
1             package Lab::Moose::Connection::WWW;
2             $Lab::Moose::Connection::WWW::VERSION = '3.880';
3             #ABSTRACT: Connection with URL requests
4              
5 1     1   2253 use v5.20;
  1         5  
6              
7              
8 1     1   7 use Moose;
  1         3  
  1         7  
9 1     1   7059 use MooseX::Params::Validate;
  1         2  
  1         7  
10 1     1   590 use Moose::Util::TypeConstraints qw(enum);
  1         3  
  1         9  
11 1     1   545 use Carp;
  1         3  
  1         82  
12              
13 1     1   8 use Lab::Moose::Instrument qw/timeout_param read_length_param/;
  1         2  
  1         62  
14              
15 1     1   493 use LWP::Simple;
  1         8665  
  1         6  
16              
17 1     1   366 use namespace::autoclean;
  1         3  
  1         8  
18              
19              
20             has ip => (
21             is => 'ro',
22             isa => 'Str',
23             required => 1,
24             );
25              
26             has port => (
27             is => 'ro',
28             isa => 'Lab::Moose::PosNum',
29             required => 1,
30             );
31              
32             sub Read {
33 0     0 0   my ( $self, %args ) = validated_hash(
34             \@_,
35             command => { isa => 'Str' },
36             );
37 0           my $command = $args{'command'};
38 0           my $url = "http://$self->ip():$self->port()$command";
39 0           return get( $url );
40             }
41              
42             sub Write {
43 0     0 0   my ( $self, %args ) = validated_hash(
44             \@_,
45             command => { isa => 'Str' },
46             );
47 0           my $command = $args{'command'};
48 0           my $url = "http://$self->ip():$self->port()$command";
49 0           get( $url );
50             }
51              
52             1;
53              
54             __END__
55              
56             =pod
57              
58             =encoding UTF-8
59              
60             =head1 NAME
61              
62             Lab::Moose::Connection::WWW - Connection with URL requests
63              
64             =head1 VERSION
65              
66             version 3.880
67              
68             =head1 SYNOPSIS
69              
70             use Lab::Moose
71            
72             my $instrument = instrument(
73             type => 'random_instrument',
74             connection_type => 'WWW',
75             connection_options => {ip => 172.22.11.2, port => 8002},
76             );
77              
78             =head1 DESCRIPTION
79              
80             This module provides a connection for devices with an integrated web
81             server.
82              
83             =head1 COPYRIGHT AND LICENSE
84              
85             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
86              
87             Copyright 2022 Mia Schambeck
88              
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut