| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bundler::MultiGem::Model::Directories { |
|
2
|
1
|
|
|
1
|
|
70745
|
use 5.006; |
|
|
1
|
|
|
|
|
12
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
15
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
5
|
1
|
|
|
1
|
|
363
|
use File::Spec::Functions qw(catpath); |
|
|
1
|
|
|
|
|
663
|
|
|
|
1
|
|
|
|
|
61
|
|
|
6
|
1
|
|
|
1
|
|
348
|
use Bundler::MultiGem::Utl::Directories qw(mk_dir rm_dir); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
49
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use constant REQUIRED_KEYS => qw(cache directories); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
347
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
Bundler::MultiGem::Model::Directory - Manipulate directories and cache |
|
10
|
|
|
|
|
|
|
= |
|
11
|
|
|
|
|
|
|
head1 VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.01 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
18
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 new |
|
22
|
|
|
|
|
|
|
Take config as argument |
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
sub new { |
|
25
|
2
|
|
|
2
|
1
|
297
|
my $class = shift; |
|
26
|
2
|
|
100
|
|
|
9
|
my $self = shift // {}; |
|
27
|
2
|
|
|
|
|
3
|
bless $self, $class; |
|
28
|
2
|
|
|
|
|
5
|
return $self; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 validates |
|
32
|
|
|
|
|
|
|
Validates current configuration |
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
sub validates { |
|
35
|
2
|
|
|
2
|
1
|
1106
|
my $self = shift; |
|
36
|
2
|
|
|
|
|
6
|
my %keys = map { $_ => 1 } keys(%$self); |
|
|
3
|
|
|
|
|
7
|
|
|
37
|
2
|
|
|
|
|
6
|
foreach my $k (REQUIRED_KEYS) { |
|
38
|
3
|
100
|
|
|
|
9
|
if (! defined($keys{$k}) ) { |
|
39
|
1
|
|
|
|
|
9
|
die "Missing key: $k for Bundler::MultiGem::Model::Directories"; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
1
|
|
|
|
|
3
|
return $self; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 cache |
|
46
|
|
|
|
|
|
|
cache getter |
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
sub cache { |
|
49
|
0
|
|
|
0
|
1
|
|
my ($self, $key) = @_; |
|
50
|
0
|
0
|
|
|
|
|
if (!defined $key) { |
|
51
|
0
|
|
|
|
|
|
return $self->{cache}; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
0
|
|
|
|
|
|
return $self->{cache}->{$key} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 dirs |
|
57
|
|
|
|
|
|
|
dirs getter |
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
sub dirs { |
|
60
|
0
|
|
|
0
|
1
|
|
my ($self, $key) = @_; |
|
61
|
0
|
0
|
|
|
|
|
if (!defined $key) { |
|
|
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $self->{directories}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
elsif ($key eq 'root') { |
|
65
|
0
|
|
|
|
|
|
return $self->{directories}->{root}; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
return catpath($self->dirs('root'), $self->{directories}->{$key}); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 apply_cache |
|
71
|
|
|
|
|
|
|
apply_cache current configuration |
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
sub apply_cache { |
|
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
75
|
0
|
|
|
|
|
|
my $root = $self->dirs('root'); |
|
76
|
0
|
|
|
|
|
|
mk_dir($root); |
|
77
|
0
|
|
|
|
|
|
foreach my $k (keys(%{$self->cache})){ |
|
|
0
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
if (! $self->cache->{$k}) { |
|
79
|
0
|
|
|
|
|
|
rm_dir $self->dirs($k); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
|
|
|
|
|
mk_dir $self->dirs($k); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
}; |
|
86
|
|
|
|
|
|
|
1; |