blib/lib/XAS/Apps/Test/Echo/Client.pm

filter: Statementstmt 36.6% 11 / 30 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 50.0% 2 / 4 totaltotal 39.0% 16 / 41 CC 1 SCAR 4.5
CC
1
Cov
37%
setup
2.0
do_echo
2.0
main
2.0
CRAP 1.6
« blib/lib/XAS/Lib/Modules/Log/Console.pm ↑ Summary blib/lib/XAS/Lib/Modules/Log/Syslog.pm »
1 package XAS::Apps::Test::Echo::Client;
2  
3 1 our $VERSION = '0.02';
4  
5 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use XAS::Lib::Net::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 use XAS::Class
9 1 version => $VERSION,
10 base => 'XAS::Lib::App',
11 accessors => 'handle port host send'
12 1 ▶;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # ----------------------------------------------------------------------
15 # Public Methods
16 # ----------------------------------------------------------------------
17  
18 sub setup {
19 0 ▶ my $self = shift;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
20  
21 0 $self->{handle} = XAS::Lib::Net::Client->new(
22 -port => $self->port,
23 -host => $self->host,
24 );
25  
26 }
27  
28 sub do_echo {
29 0 ▶ my $self = shift;
Subroutine do_echo: not called CC=1 SCAR=6.9
Pod undocumented
30  
31 0 my $message;
32  
33 0 $self->handle->connect();
34 0 $self->handle->puts($self->send);
35  
36 0 $message = $self->handle->gets();
37 0 $self->handle->disconnect();
38  
39 0 $self->log->info(sprintf("echo = %s", $message));
40  
41 }
42  
43 sub main {
44 0 ▶ my $self = shift;
Subroutine main: not called CC=1 SCAR=6.9
Pod documented
45  
46 0 $self->setup();
47  
48 0 $self->log->debug('Starting main section');
49  
50 0 $self->do_echo();
51  
52 0 $self->log->debug('Ending main section');
53  
54 }
55  
56 sub options {
57 0 ▶ my $self = shift;
Subroutine options: not called CC=1 SCAR=6.9
Pod documented
58  
59 0 $self->{send} = '';
60 0 $self->{port} = '9505';
61 0 $self->{host} = 'localhost';
62  
63 return {
64 'port=s' => \$self->{port},
65 'host=s' => \$self->{host},
66 'send=s' => \$self->{send},
67 0 };
68  
69 }
70  
71 # ----------------------------------------------------------------------
72 # Private Methods
73 # ----------------------------------------------------------------------
74  
75 1 1;
76  
77 __END__
78  
79 =head1 NAME
80  
81 XAS::Apps::Test::Echo::Client - This module will send data to the echo server
82  
83 =head1 SYNOPSIS
84  
85 use XAS::Apps::Test::Echo::Client;
86  
87 my $app = XAS::Apps::Test::Echo::Client->new(;
88 -throws => 'echo-client',
89 );
90  
91 exit $app->run();
92  
93 =head1 DESCRIPTION
94  
95 This module will send a message to the echo server. This message should be
96 'echoed' back.
97  
98 =head1 CONFIGURATION
99  
100 There is no additional configuration.
101  
102 =head1 OPTIONS
103  
104 This module provides these additonal cli options.
105  
106 =head2 --host
107  
108 The host the echo server resides on. Defaults to 'localhost'.
109  
110 =head2 --port
111  
112 The port it is listening on. Defaults to '9505'.
113  
114 =head2 --send
115  
116 The text to be "echoed" back.
117  
118 =head1 SEE ALSO
119  
120 =over 4
121  
122 =item bin/echo-client.pl
123  
124 =item L<XAS|XAS>
125  
126 =back
127  
128 =head1 AUTHOR
129  
130 Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
131  
132 =head1 COPYRIGHT AND LICENSE
133  
134 Copyright (C) 2012 by Kevin L. Esteb
135  
136 This is free software; you can redistribute it and/or modify it under
137 the terms of the Artistic License 2.0. For details, see the full text
138 of the license at http://www.perlfoundation.org/artistic_license_2_0.
139  
140 =cut
« blib/lib/XAS/Lib/Modules/Log/Console.pm ↑ Summary blib/lib/XAS/Lib/Modules/Log/Syslog.pm »