blib/lib/Seis/IO.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 17 totaltotal 0.0% 0 / 104 CC 4 SCAR 10.9
CC
4
Cov
0%
e
6.0
d
6.0
f
6.0
CRAP 3.0
1 package Seis::IO;
2 use strict;
3 use warnings;
4 use utf8;
5 use 5.018_000;
6  
7 sub _new {
8 my ($class, $path) = @_;
9 bless { path => $path }, $class;
10 }
11  
12 # return Seis::IO->_new_with_fh($_[0], $fh);
13 sub _new_with_fh {
14 my ($class, $path, $fh) = @_;
15 bless { path => $path, fh => $fh }, $class;
16 }
17  
18 sub lines {
19 my $self = shift;
20 my $fh = $self->{fh};
21 my @lines = <$fh>;
22 @lines;
23 }
24  
25 sub eof:method {
26 warn CORE::eof($_[0]->{fh});
27 CORE::eof($_[0]->{fh});
28 }
29  
30 sub get:method {
31 my $self = shift;
32 my $fh = $self->{fh};
33 $self->{ins}++;
34 my $line = scalar(<$fh>);
35 chop($line);
36 $line;
37 }
38  
39 sub print:method {
40 my $self = shift;
41 print {$self->{fh}} shift;
42 }
43  
44 sub close:method {
45 my $self = shift;
46 close $self->{fh};
47 }
48  
49 sub getc:method {
50 my $self = shift;
51 getc $self->{fh};
52 }
53  
54 sub ins {
55 my $self = shift;
56 $self->{ins};
57 }
58  
59 sub say:method {
60 my $self = shift;
61 CORE::say {$self->{fh}} @_;
62 }
63  
64 sub write:method {
65 my $self = shift;
66 CORE::print {$self->{fh}} @_;
67 }
68  
69 sub read:method {
70 my ($self, $len) = @_;
71 CORE::read($self->{fh}, my $buf, $len);
72 return $buf;
73 }
74  
75 # Note. Following file testing cases are optimizable by XS.
76 sub e { -e $_[0]->{path} ? Bool::true() : Bool::false() }
77 sub d { -d $_[0]->{path} ? Bool::true() : Bool::false() }
78 sub s { -s $_[0]->{path} } # size.
79 sub f { -f $_[0]->{path} ? Bool::true() : Bool::false() }
80  
81 sub copy {
82 require File::Copy;
83 File::Copy::copy($_[0]->{path}, $_[1])
84 or Seis::Exception::IO->throw("$!");
85 }
86  
87 1;
88