File Coverage

blib/lib/XAS/Lib/Mixins/Bufops.pm
Criterion Covered Total %
statement 6 19 31.5
branch 0 4 0.0
condition n/a
subroutine 2 4 50.0
pod 2 2 100.0
total 10 29 34.4


line stmt bran cond sub pod time code
1             package XAS::Lib::Mixins::Bufops;
2              
3             our $VERSION = '0.01';
4              
5 1     1   779 use Params::Validate qw(SCALAR SCALARREF);
  1         2  
  1         60  
6             use XAS::Class
7 1         8 debug => 0,
8             version => $VERSION,
9             base => 'XAS::Base',
10             utils => ':validation',
11             mixins => 'buf_slurp buf_get_line'
12 1     1   4 ;
  1         1  
13              
14             # ----------------------------------------------------------------------
15             # Public Methods
16             # ----------------------------------------------------------------------
17              
18             sub buf_slurp {
19 0     0 1   my $self = shift;
20 0           my ($buffer, $pos) = validate_params(\@_, [
21             { type => SCALARREF },
22             { type => SCALAR },
23             ]);
24              
25 0           my $output;
26              
27 0 0         if ($output = substr($$buffer, 0, $pos)) {
28              
29 0           substr($$buffer, 0, $pos) = '';
30              
31             }
32              
33 0           return $output;
34              
35             }
36              
37             sub buf_get_line {
38 0     0 1   my $self = shift;
39 0           my ($buffer, $eol) = validate_params(\@_, [
40             { type => SCALARREF },
41             { type => SCALAR | SCALARREF },
42             ]);
43              
44 0           my $pos;
45             my $output;
46              
47 0 0         if ($$buffer =~ m/$eol/g) {
48              
49 0           $pos = pos($$buffer);
50 0           $output = $self->buf_slurp($buffer, $pos);
51              
52             }
53              
54 0           return $output;
55              
56             }
57              
58             # ----------------------------------------------------------------------
59             # Private Methods
60             # ----------------------------------------------------------------------
61              
62             1;
63              
64             __END__