# HG changeset patch # User heiko@jumper # Date 1231188296 -3600 # Node ID 7ccc679ac5db343912a41b9a429f0b36acfb7050 # Parent d6f68132954297b78b05936cbfd996e313c715de Added POD documentation to examples/test-server Quancom::Test::Server. The examples/test-sever even understand --help and --man now. diff -r d6f681329542 -r 7ccc679ac5db examples/test-server --- a/examples/test-server Sun Jan 04 23:44:45 2009 +0100 +++ b/examples/test-server Mon Jan 05 21:44:56 2009 +0100 @@ -8,9 +8,64 @@ use warnings; use POSIX qw(tmpnam); use Getopt::Long; +use Pod::Usage; use Quancom::Test::Server; $SIG{INT} = sub { warn "got INT, exit now\n"; exit 0; }; +GetOptions( + "help" => sub { pod2usage(-verbose => 0, exit => 0) }, + "man" => sub { pod2usage(-verbose => 2, exit => 0) }, +) or pod2usage; + my $server = new Quancom::Test::Server @ARGV ? $ARGV[0] : tmpnam(); $server->run; + +__END__ + +=head1 NAME + +test-server + +=head1 SYNOPSIS + + test-server [socket|[address:]port|-] + +=head1 DESCRIPTION + +This command starts a test server simulating a Quancom USB-OPTO device. +It's use is for testing purpose only (testing the Quancom.pm module). + +=head1 INVOCATION + +On invocation you may pass a parameter: + +=over + +=item I + +This should be the name of a socket file. The socket file must not +exist, it will be created. The name has contain at least on slash ("/") +to be distinguished from a port number. + +=item [I]I + +Using this the server will bind to the specified port on 0.0.0.0 or the +address supplied. + +=item B<-> + +Using a single "-" the server will communicate over STDIN/STDOUT. Some +changes in behaviour are implicit set. See L for +more details. This option is for testing the test server. + +=item B + +If you do not pass anything, the server creates a temporary socket file. + +=back + +In all cases, the server tells you on STDERR about the "channel" used +for communication. + +=cut diff -r d6f681329542 -r 7ccc679ac5db lib/Quancom/Test/Server.pm --- a/lib/Quancom/Test/Server.pm Sun Jan 04 23:44:45 2009 +0100 +++ b/lib/Quancom/Test/Server.pm Mon Jan 05 21:44:56 2009 +0100 @@ -4,6 +4,24 @@ # Quancom.pm module and should work like the real USB-OPTO device of # Quancom. +# Quancom test/simulator server +# Copyright (C) 2008 Heiko Schlittermann +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Heiko Schlittermann + use strict; use warnings; use Carp; @@ -166,3 +184,34 @@ } 1; + +__END__ + +=head1 NAME + +Quancom::Test::Server + +=head1 SYNOPSIS + + use Quancom::Test::Server; + + my $server = new Quancom::Test::Server "/tmp/socket"; + $server->run(); + +=head1 METHODS + +=over + +=item constructor B( I<$address> ) + +This creates a new server on the I<$address>. The I<$address> may be one +of the following: + + "-" server communications on STDIN/STDOUT + [address:]port server binds to port I on address I
+ or 0.0.0.0 + filename server creates and binds to the named socket + file (the file gets created by the server and + will be removed afterwards) + +=back