Beep/Linux/beep.pm

filter: Statementstmt 61.9% 13 / 21 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 3 totaltotal 46.5% 20 / 43 CC 6 SCAR 12.3
CC
6
Cov
55%
_search_path
4.6
new
3.6
play
2.0
CRAP 3.4
« Beep/Linux/PP.pm ↑ Summary
1 package Audio::Beep::Linux::beep;
2  
3 1 $Audio::Beep::Linux::beep::VERSION = 0.11;
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub new {
Subroutine new: called CC=3 SCAR=12.7
Pod undocumented
8 1 my $class = shift;
9 1 my %hash = @_;
10 1 ▶ $hash{path} ||= _search_path();
Condition33%1/3
$hash{"path"} ||= _search_path()
l!l&&r!l&&!r
001
MC/DC0%0/2
$hash{"path"} ||= _search_path()
$hash{"path"} _search_path()
Truth table33%1/3
A ||= B
A= $hash{"path"}B= _search_path()
ABresult
1X1
011
000
11 1 ▶ return unless $hash{path};
Branch: 1 branch
BranchTrueFalseTotal
unless $hash{"path"} 1 0 1
12 0 return bless \%hash, $class;
13 }
14  
15 0 ▶sub play {
Subroutine play: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my $self = shift;
17 0 my ($pitch, $duration) = @_;
18 0 return `\Q$self->{path}\E -l $duration -f $pitch`;
19 }
20  
21 0 ▶sub rest {
Subroutine rest: not called CC=1 SCAR=6.9
Pod undocumented
22 0 my $self = shift;
23 0 my ($duration) = @_;
24 0 select undef, undef, undef, $duration/1000;
25 0 return 1;
26 }
27  
28 1 ▶sub _search_path {
Subroutine _search_path: called CC=4 SCAR=15.2
29 1 my @prob_paths = qw(
30 /usr/bin/beep
31 /usr/local/bin/beep
32 /bin/beep
33 );
34 1 ▶ do { return $_ if -e and -x _ } for @prob_paths;
Branch: 1 branch
BranchTrueFalseTotal
if -e $_ and -x _ 0 3 3
Condition33%1/3
-e $_ and -x _
!ll&&!rl&&r
300
MC/DC0%0/2
-e $_ and -x _
-e $_ -x _
Truth table33%1/3
A and B
A= -e $_B= -x _
ABresult
0X0
100
111
35 1 return;
36 }
37  
38 =head1 NAME
39  
40 Audio::Beep::Linux::beep - Audio::Beep player module using the B<beep> program
41  
42 =head1 SYNOPIS
43  
44 my $player = Audio::Beep::Linux::beep->new([%options]);
45  
46 =head1 USAGE
47  
48 The C<new> class method can receive as option in hash fashion the following
49 directives
50  
51 =over 4
52  
53 =item path => '/full/path/to/beep'
54  
55 With the path option you can set the full path to the B<beep> program in
56 the object. If you don't use this option the new method will look anyway
57 in some likely places where B<beep> should be before returning undef.
58  
59 =back
60  
61 =head1 NOTES
62  
63 The B<beep> program is a Linux program wrote by Johnathan Nightingale.
64 You should find C sources in the tarball where you found this file.
65 The B<beep> program needs to be (usually) executed as root to actually work.
66 Please check C<beep(1)> for more info.
67  
68 =head1 BUGS
69  
70 None known.
71  
72 =head1 COPYRIGHT
73  
74 Copyright 2003-2004 Giulio Motta L<giulienk@cpan.org>.
75  
76 This library is free software; you can redistribute it and/or
77 modify it under the same terms as Perl itself.
78  
79 =cut
80  
81 1 1;
« Beep/Linux/PP.pm ↑ Summary