blib/lib/Acme/Meow.pm

filter: Statementstmt 33.3% 15 / 45 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 40.0% 4 / 10 Podpod 100% 6 / 6 totaltotal 28.7% 25 / 87 CC 11 SCAR 24.2
CC
11
Cov
22%
milk
20.0
nip
20.0
_kitty_status
12.0
CRAP 11.3
↑ Summary
1 package Acme::Meow;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 require Exporter;
7 3 ▶use base qw[ Exporter ];
Subroutine BEGIN: called CC=1 SCAR=0.0
8 =head1 NAME
9  
10 Acme::Meow - It's the kitty you've always wanted
11  
12 =head1 VERSION
13  
14 Version 0.01 - please note this is a preview release, the API may change
15 $Id: Meow.pm 558 2007-09-07 12:14:11Z f00li5h $
16 =cut
17  
18 3 our $VERSION = '0.01';
19 =head1 SYNOPSIS
20  
21 This module is intended for use by folks who's leases
22 specify that they are not allowed to have any pets
23  
24 use Acme::Meow;
25  
26 my $kitty = Acme::Meow->new();
27 $kitty->pet();
28 $kitty->feed();
29  
30  
31 =head1 FUNCTIONS
32  
33 =head2 new - kitty constructor
34  
35 Currently only abstract kitties are available so no options are available,
36 although they may be added in the future.
37  
38 This method will take a hashref of options as required.
39  
40 =cut
41  
42 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
43 1 bless{},shift
44 }
45  
46 =head1 METHODS
47  
48 =head2 pet - pet the kitty
49  
50 =cut
51  
52 3 our @snacks = qw[ milk nip ];
53  
54 0 ▶sub pet {
Subroutine pet: not called CC=2 SCAR=17.9
Pod documented
55 0 my($kitty) =@_;
56  
57 0 my @reactions = qw[ purr nuzzle meow ];
58  
59 0 $kitty->{'<3'} ++;
60 0 $kitty->{'favs'} = {
61 snack => @snacks[ rand @snacks ]
62 };
63  
64 print $kitty->_kitty_status,
65 0 ▶ $reactions[ rand @reactions ], $kitty->{'<3'} > 15 ? '<3' : ''
Branch: 1 branch
BranchTrueFalseTotal
$kitty->{'<3'} > 15 ? : 0 0 0
66
67  
68 }
69  
70  
71 =head2 feed - give the kitty a snack
72  
73 the kitty does need to eat, otherwise it will get unhealthy
74  
75 =cut
76  
77 0 ▶sub feed {
Subroutine feed: not called CC=2 SCAR=17.9
Pod documented
78  
79 0 my($kitty) =@_;
80  
81 0 my @reactions = ( 'crunch', 'lap lap', '');
82  
83 0 ▶ if (!$kitty->is_sleeping()){
Branch: 1 branch
BranchTrueFalseTotal
if (not $kitty->is_sleeping) { } 0 0 0
84 0 $kitty->{'^_^'} ++;
85 0 $kitty->{'<3' } += 0.5;
86 }
87 else {
88 0 $kitty->{'^_^'} -= 0.5;
89 0 $kitty->{'<3' } += 0.25;
90 }
91  
92 0 print $kitty->_kitty_status,
93 $reactions[ rand @reactions ];
94  
95 }
96  
97 =head1 EXPORTS
98  
99 by default this package exports some methods for playing with your
100 kitties.
101  
102 =head2 milk - give milk to a kitty.
103  
104 if not called directly on a kitty, $_ will be checked for a kitty;
105  
106 =cut
107  
108 3 our @EXPORT = qw(&milk &nip); # afunc is a function
109 # @EXPORT_OK = qw(&%hash *typeglob); # explicit prefix on &bfunc
110  
111 0 ▶sub milk {
Subroutine milk: not called CC=4 SCAR=30.0
Pod documented
112 0 my $kitty;
113  
114 0 ▶ if(not @_ and ref $_ eq __PACKAGE__){
Branch: 1 branch
BranchTrueFalseTotal
if (not @_ and ref $_ eq __PACKAGE__) 0 0 0
Condition0%0/3
not @_ and ref $_ eq __PACKAGE__
!ll&&!rl&&r
000
MC/DC0%0/2
not @_ and ref $_ eq __PACKAGE__
not @_ ref $_ eq __PACKAGE__
Truth table0%0/3
not(A) and B
A= not @_B= ref $_ eq __PACKAGE__
ABresult
0X0
100
111
115 0 $kitty = $_
116 }
117 0 ▶ if( @_ ){ $kitty = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
118  
119 0 $kitty->feed( 'milk' );
120 }
121  
122 =head2 nip - give nip to a kitty.
123  
124 if not called directly on a kitty, $_ will be checked for a kitty;
125  
126 =cut
127 0 ▶sub nip {
Subroutine nip: not called CC=4 SCAR=30.0
Pod documented
128  
129 0 my $kitty;
130  
131 0 ▶ if(not @_ and ref $_ eq __PACKAGE__){
Branch: 1 branch
BranchTrueFalseTotal
if (not @_ and ref $_ eq __PACKAGE__) 0 0 0
Condition0%0/3
not @_ and ref $_ eq __PACKAGE__
!ll&&!rl&&r
000
MC/DC0%0/2
not @_ and ref $_ eq __PACKAGE__
not @_ ref $_ eq __PACKAGE__
Truth table0%0/3
not(A) and B
A= not @_B= ref $_ eq __PACKAGE__
ABresult
0X0
100
111
132 0 $kitty = $_
133 }
134 0 ▶ if( @_ ){ $kitty = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
135  
136 0 $kitty->feed( 'nip' );
137  
138 }
139  
140  
141 =head2 is_sleeping
142  
143 This method will tell you if your kitty is having a cat nap.
144 Kittens may be very cranky during their nap time, and waking them may be a bad
145 idea.
146  
147 =cut
148 0 ▶sub is_sleeping {
Subroutine is_sleeping: not called CC=1 SCAR=6.9
Pod documented
149  
150 0 my($kitty) =@_;
151 0 0; #TODO: our kitties are currently insomniacs
152 }
153  
154 =head2 _kitty_status
155  
156 private
157  
158 =cut
159 0 ▶sub _kitty_status {
Subroutine _kitty_status: not called CC=3 SCAR=24.8
160  
161 0 my($kitty) =@_;
162 0 ▶ return 'zZzZ' if $kitty->is_sleeping();
Branch: 1 branch
BranchTrueFalseTotal
if $kitty->is_sleeping 0 0 0
163 0 ▶ $kitty->{'<3'} > 5 ? '=-_-=' : '=^_^=';
Branch: 1 branch
BranchTrueFalseTotal
$kitty->{'<3'} > 5 ? : 0 0 0
164  
165 }
166  
167 =head1 AUTHOR
168  
169 FOOLISH, C<< <foolish at cpan.org> >>
170  
171 =head1 BUGS
172  
173 Please report any bugs or feature requests to
174 C<bug-acme-meow at rt.cpan.org>, or through the web interface at
175 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Acme-Meow>.
176 I will be notified, and then you'll automatically be notified of progress on
177 your bug as I make changes.
178  
179 =head1 TODO
180  
181 =over 4
182  
183 =item play
184  
185 it'd be nince to play games with the kitty too
186  
187 $kitty->play( 'game' );
188  
189 =back
190  
191 =head1 SUPPORT
192  
193 You can find documentation for this module with the perldoc command.
194  
195 perldoc Acme::Meow
196  
197 You can also look for information at:
198  
199 =over 4
200  
201 =item * AnnoCPAN: Annotated CPAN documentation
202  
203 L<http://annocpan.org/dist/Acme-Meow>
204  
205 =item * CPAN Ratings
206  
207 L<http://cpanratings.perl.org/d/Acme-Meow>
208  
209 =item * RT: CPAN's request tracker
210  
211 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Acme-Meow>
212  
213 =item * Search CPAN
214  
215 L<http://search.cpan.org/dist/Acme-Meow>
216  
217 =back
218  
219 =head1 ACKNOWLEDGEMENTS
220  
221 =head1 COPYRIGHT & LICENSE
222  
223 Copyright 2007 FOOLISH, all rights reserved.
224  
225 This program is free software; you can redistribute it and/or modify it
226 under the same terms as Perl itself.
227  
228 =cut
229  
230 3 1; # End of Acme::Meow
↑ Summary