| 1 | package VCS::Dir; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use VCS::File; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | my $PREFIX = 'VCS'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 8 | 1 | my $container_classtype = shift; | |||||||||||||||||||
| 9 | 1 | $container_classtype =~ s#^$PREFIX##; | |||||||||||||||||||
| 10 | 1 | my ($hostname, $impl_class, $path, $query) = VCS->parse_url(@_); | |||||||||||||||||||
| 11 | 1 | VCS->class_load($impl_class); | |||||||||||||||||||
| 12 | 1 | my $this_class = "$impl_class$container_classtype"; | |||||||||||||||||||
| 13 | 1 | return $this_class->new(@_); | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # assumes no query string | ||||||||||||||||||||
| 17 | 1 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 18 | 1 | my($class, $url) = @_; | |||||||||||||||||||
| 19 | 1 | my ($hostname, $impl_class, $path, $query) = VCS->parse_url($url); | |||||||||||||||||||
| 20 | 1 | ▶ | if (substr($path, -1, 1) ne '/') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 0 | $path .= '/'; | |||||||||||||||||||
| 22 | 0 | $url .= '/'; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | 1 | my $self = {}; | |||||||||||||||||||
| 25 | 1 | $self->{HOSTNAME} = $hostname; | |||||||||||||||||||
| 26 | 1 | $self->{IMPL_CLASS} = $impl_class; | |||||||||||||||||||
| 27 | 1 | $self->{PATH} = $path; | |||||||||||||||||||
| 28 | 1 | $self->{URL} = $url; | |||||||||||||||||||
| 29 | 1 | bless $self, $class; | |||||||||||||||||||
| 30 | 1 | return $self; | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | ▶ | sub url { | ||||||||||||||||||
|
Subroutine
url: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||
| 35 | 0 | $self->{URL}; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub content { | ||||||||||||||||||
|
Subroutine
content: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | sub path { | ||||||||||||||||||
|
Subroutine
path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 42 | 0 | my $self = shift; | |||||||||||||||||||
| 43 | 0 | $self->{PATH}; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | sub tags { | ||||||||||||||||||
|
Subroutine
tags: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||
| 48 | 0 | my $rh = {}; # result hash | |||||||||||||||||||
| 49 | 0 | my @files = $self->recursive_read_dir(); | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | my $url; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | foreach my $file (@files) { | |||||||||||||||||||
| 54 | 0 | ▶ | my $vcsfile = eval { VCS::File->new('vcs://'.$self->{HOSTNAME}.'/'.$self->{IMPL_CLASS}.'/'.$file) } or next; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | my $file_tag_information = $vcsfile->tags(); | |||||||||||||||||||
| 56 | 0 | foreach my $filetag (keys(%$file_tag_information)) { | |||||||||||||||||||
| 57 | 0 | $rh->{$filetag}->{$file} = $file_tag_information->{$filetag}; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | return $rh; | |||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 7 | ▶ | sub recursive_read_dir { | ||||||||||||||||||
|
Subroutine
recursive_read_dir: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||
| 67 | 7 | my $self = shift; | |||||||||||||||||||
| 68 | 7 | my ($dir) = @_; | |||||||||||||||||||
| 69 | 7 | ▶ | $dir ||= $self->path(); # let it take path if its not been | ||||||||||||||||||
|
Condition33%1/3
$dir ||= $self->path
MC/DC0%0/2
$dir ||= $self->path
$dir
$self->path
Truth table33%1/3
A ||= B
A= $dirB= $self->path
| |||||||||||||||||||||
| 70 | # defined, i'm not really sure about this, | ||||||||||||||||||||
| 71 | # to be honest the whole things need an | ||||||||||||||||||||
| 72 | # an overhaul in the way it works, | ||||||||||||||||||||
| 73 | # but for now i'm just happy to get | ||||||||||||||||||||
| 74 | # my work done. - Greg | ||||||||||||||||||||
| 75 | 7 | ▶ | $dir.='/' unless (substr($dir,-1,1) eq '/'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 7 | my @files; | |||||||||||||||||||
| 77 | 7 | opendir(DIR,$dir); | |||||||||||||||||||
| 78 | 7 | my @contents = grep { (!/^\.\.?$/) } readdir(DIR); | |||||||||||||||||||
| 79 | 7 | @contents = grep { (!/,v$/) } @contents; # RCS files, shouldn't matter if they are RCS/*,v or just *,v | |||||||||||||||||||
| 80 | 7 | @contents = grep { (!/^CVS$/) } @contents; | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 7 | closedir(DIR); | |||||||||||||||||||
| 83 | 7 | foreach my $content (@contents) { | |||||||||||||||||||
| 84 | 12 | ▶ | if (-d $dir.$content) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | 6 | push(@files,($self->recursive_read_dir($dir.$content))); | |||||||||||||||||||
| 86 | } else { | ||||||||||||||||||||
| 87 | 6 | push(@files,$dir.$content); | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | 7 | return @files; | |||||||||||||||||||
| 91 | } | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | ▶ | sub read_dir { | ||||||||||||||||||
|
Subroutine
read_dir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 94 | 0 | my ($self, $dir) = @_; | |||||||||||||||||||
| 95 | 0 | local *DIR; | |||||||||||||||||||
| 96 | 0 | opendir DIR, $dir; | |||||||||||||||||||
| 97 | 0 | my @d = grep { (!/^\.\.?$/) } readdir DIR; | |||||||||||||||||||
| 98 | 0 | closedir DIR; | |||||||||||||||||||
| 99 | #warn "d: @d\n"; | ||||||||||||||||||||
| 100 | 0 | @d; | |||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | 1 | 1; | |||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | __END__ | ||||||||||||||||||||