| 1 | package Net::Peep::Peck; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | require 5.00503; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # use warnings; # commented out for 5.005 compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Net::Peep::Client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Net::Peep::BC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use vars qw{ @ISA %EXPORT_TAGS @EXPORT_OK @EXPORT $VERSION }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | @EXPORT = qw( ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | $VERSION = do { my @r = (q$Revision: 1.4 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use constant PROT_MAJORVER => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use constant PROT_MINORVER => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use constant PROT_CLIENTEVENT => 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use constant PORT => '1999'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | my $this = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | bless $this, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | $this; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } # end sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | sub peck { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peck: called CC=7 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | my $client = new Net::Peep::Client; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | $client->name('peck'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | my ($type,$sound,$location,$volume,$priority,$dither,$autodiscovery) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | = (0,0,0,255,128,255,0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | my %options = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'type=s' => \$type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'sound=s' => \$sound, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'location=s' => \$location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'volume=s' => \$volume, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'priority=s' => \$priority, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'dither=s' => \$dither, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'autodiscovery!' => \$autodiscovery, # override Net::Peep::Client's default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | $client->initialize(%options) || $client->pods(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | ▶ | $client->parser( sub { } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | my $conf = $client->configure(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | ▶ | if ($conf->getOption('autodiscovery')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | die "Error: Autodiscovery is not supported by the peck client."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | ▶ | unless ($conf->optionExists('server') && $conf->getOption('server') && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$conf->optionExists("server") and $conf->getOption("server") and $conf->optionExists("port") and $conf->getOption("port")
$conf->optionExists("server") and $conf->getOption("server") and $conf->optionExists("port")
$conf->optionExists("server") and $conf->getOption("server")
MC/DC0%0/4
$conf->optionExists("server") and $conf->getOption("server") and $conf->optionExists("port") and $conf->getOption("port")
$conf->optionExists("server")
$conf->getOption("server")
$conf->optionExists("port")
$conf->getOption("port")
Truth table20%1/5
A and B and C and D
A= $conf->optionExists("server")B= $conf->getOption("server")C= $conf->optionExists("port")D= $conf->getOption("port")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $conf->optionExists('port') && $conf->getOption('port')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $client->pods("Error: You must provide a server and port option."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | my $broadcast = new Net::Peep::BC ('peck',$conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | $broadcast->send( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'peck', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | priority => $priority, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | volume => $volume, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | dither => $dither, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sound => $sound | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } # end sub peck | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # returns a logging object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub logger { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logger: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ( ! exists $self->{'__LOGGER'} ) { $self->{'__LOGGER'} = new Net::Peep::Log } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return $self->{'__LOGGER'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } # end sub logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub pecker { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pecker: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # tee hee | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $self->{"__PECKER"} = Net::Peep::BC->new() unless exists $self->{"__PECKER"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return $self->{"__PECKER"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } # end sub pecker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||