| 1 | package DMOSS::File; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: DMOSS file object | ||||||||||||||||||||||||||||
| 3 | 3 | $DMOSS::File::VERSION = '0.01_2'; | |||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use File::Slurp qw/slurp/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 1 | my ($class, $basedir, $fullpath) = @_; | |||||||||||||||||||||||||||
| 12 | 1 | my $self = bless({}, $class); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | $self->fullpath($fullpath); | |||||||||||||||||||||||||||
| 15 | 1 | ▶ | $self->basename(File::Basename::basename($fullpath)) if $fullpath; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | $self->dirname(File::Basename::dirname($fullpath)) if $fullpath; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 1 | my $path = $fullpath; | |||||||||||||||||||||||||||
| 18 | 1 | ▶ | $path =~ s/$basedir//g if $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | $path =~ s/^\/+//g if $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 1 | $self->{path} = $path; | |||||||||||||||||||||||||||
| 21 | 1 | ▶ | $self->{isfile} = 1 unless ($fullpath and -d $fullpath); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fullpath and -d $fullpath
MC/DC0%0/2
$fullpath and -d $fullpath
$fullpath
-d $fullpath
Truth table33%1/3
A and B
A= $fullpathB= -d $fullpath
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | #$self->content(slurp $fullpath) if -e $fullpath; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | return $self; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub basename { | ||||||||||||||||||||||||||
|
Subroutine
basename: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 0 | my ($self, $basename) = @_; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | $self->{basename} = $basename if $basename; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | return $self->{basename}; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub fullpath { | ||||||||||||||||||||||||||
|
Subroutine
fullpath: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 1 | my ($self, $fullpath) = @_; | |||||||||||||||||||||||||||
| 37 | 1 | ▶ | $self->{fullpath} = $fullpath if $fullpath; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | return $self->{fullpath}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub dirname { | ||||||||||||||||||||||||||
|
Subroutine
dirname: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | my ($self, $dirname) = @_; | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | $self->{dirname} = $dirname if $dirname; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | return $self->{dirname}; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub path { | ||||||||||||||||||||||||||
|
Subroutine
path: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | $self->{path} = $path if $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | return $self->{path}; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 0 | my ($self, $type) = @_; | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | $self->{type} = $type if $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | return $self->{type}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub content { | ||||||||||||||||||||||||||
|
Subroutine
content: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 0 | my ($self, $content) = @_; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | $self->{content} = $content if $content; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | return $self->{content}; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub isfile { | ||||||||||||||||||||||||||
|
Subroutine
isfile: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | my ($self, $isfile) = @_; | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | $self->{isfile} = $isfile if $isfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | return $self->{isfile}; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 3 | 1; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||||||||||