| 1 | package VCI::Abstract::Directory; | ||||||||||||
| 2 | 4 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | |||||||||||||
| 4 | 4 | with 'VCI::Abstract::Committable', 'VCI::Abstract::FileContainer'; | |||||||||||
| 5 | |||||||||||||
| 6 | # Because composed roles don't call BUILD, this is in all objects that | ||||||||||||
| 7 | # implment Committable. | ||||||||||||
| 8 | 0 | ▶ | sub BUILD { shift->_no_time_without_revision; } | ||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 9 | |||||||||||||
| 10 | # For helping build directory contents for some VCSes. | ||||||||||||
| 11 | 0 | ▶ | sub _set_contents_from_list { | ||||||||||
|
Subroutine
_set_contents_from_list: not called CC=10 SCAR=47.0
| |||||||||||||
| 12 | 0 | my ($self, $dir_names, $file_names, $strip_root) = @_; | |||||||||||
| 13 | |||||||||||||
| 14 | # Sorting assures that parent directories will always be in the array | ||||||||||||
| 15 | # before child directories. | ||||||||||||
| 16 | 0 | my @dir_array = sort {length($a) <=> length($b)} @$dir_names; | |||||||||||
| 17 | 0 | my $root_path = $self->path->stringify; | |||||||||||
| 18 | 0 | my %dirs = ("$root_path" => $self); | |||||||||||
| 19 | 0 | my %dir_contents; | |||||||||||
| 20 | |||||||||||||
| 21 | # Create objects for the Directories and set their parents appropriately. | ||||||||||||
| 22 | 0 | foreach my $path (@dir_array) { | |||||||||||
| 23 | 0 | ▶ | ($path =~ s/^\Q$strip_root\E//) if defined $strip_root; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 0 | ▶ | next if !$path; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 0 | my $path_obj = Path::Abstract::Underload->new($path)->to_branch; | |||||||||||
| 26 | 0 | my $parent_name = $path_obj->parent->stringify; | |||||||||||
| 27 | 0 | my $parent = $dirs{$parent_name}; | |||||||||||
| 28 | |||||||||||||
| 29 | 0 | my $directory = $self->directory_class->new( | |||||||||||
| 30 | path => $path_obj, parent => $parent, project => $self->project); | ||||||||||||
| 31 | 0 | $dirs{$path_obj->stringify} = $directory; | |||||||||||
| 32 | |||||||||||||
| 33 | 0 | ▶ | $dir_contents{$parent_name} ||= []; | ||||||||||
|
Condition0%0/2
$dir_contents{$parent_name} ||= []
MC/DC0%0/1
$dir_contents{$parent_name} ||= []
$dir_contents{$parent_name}
Truth table0%0/2
A
A= $dir_contents{$parent_name}
| |||||||||||||
| 34 | 0 | push(@{ $dir_contents{$parent_name} }, $directory); | |||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | # Create File objects and set their parent directories correctly. | ||||||||||||
| 38 | 0 | foreach my $path (@$file_names) { | |||||||||||
| 39 | 0 | ▶ | ($path =~ s/^\Q$strip_root\E//) if defined $strip_root; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 40 | 0 | my $path_obj = Path::Abstract::Underload->new($path)->to_branch; | |||||||||||
| 41 | 0 | my $parent_name = $path_obj->parent->stringify; | |||||||||||
| 42 | 0 | ▶ | my $parent = $parent_name ? $dirs{$parent_name} : $self; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | |||||||||||||
| 44 | 0 | my $file = $self->file_class->new( | |||||||||||
| 45 | parent => $parent, path => $path_obj, project => $self->project); | ||||||||||||
| 46 | |||||||||||||
| 47 | 0 | ▶ | $dir_contents{$parent_name} ||= []; | ||||||||||
|
Condition0%0/2
$dir_contents{$parent_name} ||= []
MC/DC0%0/1
$dir_contents{$parent_name} ||= []
$dir_contents{$parent_name}
Truth table0%0/2
A
A= $dir_contents{$parent_name}
| |||||||||||||
| 48 | 0 | push(@{ $dir_contents{$parent_name} }, $file); | |||||||||||
| 49 | } | ||||||||||||
| 50 | |||||||||||||
| 51 | 0 | foreach my $dir (keys %dir_contents) { | |||||||||||
| 52 | 0 | $dirs{$dir}->{contents} = $dir_contents{$dir}; | |||||||||||
| 53 | } | ||||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | |||||||||||||
| 57 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 58 | |||||||||||||
| 59 | 4 | 1; | |||||||||||
| 60 | |||||||||||||
| 61 | __END__ | ||||||||||||