line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
File::Corresponding::Group - A group of File::Profile objects |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 DESCRIPTION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
A group of File::Profile objects which define which files belong |
9
|
|
|
|
|
|
|
together. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package File::Corresponding::Group; |
14
|
|
|
|
|
|
|
$File::Corresponding::Group::VERSION = '0.004'; |
15
|
5
|
|
|
5
|
|
71374
|
use Moose; |
|
5
|
|
|
|
|
331706
|
|
|
5
|
|
|
|
|
43
|
|
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
31278
|
use Data::Dumper; |
|
5
|
|
|
|
|
5269
|
|
|
5
|
|
|
|
|
269
|
|
18
|
5
|
|
|
5
|
|
26
|
use File::Path; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
237
|
|
19
|
5
|
|
|
5
|
|
22
|
use Path::Class; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
252
|
|
20
|
5
|
|
|
5
|
|
1156
|
use Moose::Autobox; |
|
5
|
|
|
|
|
288585
|
|
|
5
|
|
|
|
|
53
|
|
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
|
3612
|
use File::Corresponding::File::Profile; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
1296
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 PROPERTIES |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 name |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Name/description of this File Group. It should describe what's common |
31
|
|
|
|
|
|
|
between the files in the group. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
has 'name' => (is => 'ro', isa => 'Str', default => ""); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 file_profiles |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Array ref with File::Profile objects that make up the group. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
has 'file_profiles' => ( |
45
|
|
|
|
|
|
|
is => 'rw', |
46
|
|
|
|
|
|
|
isa => 'ArrayRef[File::Corresponding::File::Profile]', |
47
|
|
|
|
|
|
|
default => sub { [] }, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 corresponding($file) : ArrayRef[File::Corresponding::File::Found] |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Find files corresponding to $file (given the config in |
57
|
|
|
|
|
|
|
->file_profiles) and return found @$files. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
sub corresponding { |
61
|
9
|
|
|
9
|
1
|
4231
|
my $self = shift; |
62
|
9
|
|
|
|
|
13
|
my ($file) = @_; |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
29
|
my ($file_base, $fragment, $matching_profile) = |
65
|
|
|
|
|
|
|
$self->matching_file_fragment_profile($file); |
66
|
9
|
100
|
|
|
|
27
|
$matching_profile or return []; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $found_files = |
69
|
|
|
|
|
|
|
$self->file_profiles |
70
|
20
|
|
|
20
|
|
111
|
->grep(sub { $_ != $matching_profile }) |
71
|
13
|
|
|
13
|
|
9479
|
->map(sub { $_->new_found_if_file_exists( |
72
|
|
|
|
|
|
|
$matching_profile, |
73
|
|
|
|
|
|
|
$file_base, |
74
|
|
|
|
|
|
|
$fragment, |
75
|
7
|
|
|
|
|
151
|
) }); |
76
|
|
|
|
|
|
|
|
77
|
7
|
|
|
|
|
8431
|
return $found_files; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 matching_file_fragment_profile($file) : $file_fragment, File::Corresponding::File::Profile | () |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Return two item list with the $file_fragment and first profile that |
85
|
|
|
|
|
|
|
matches $file, or an empty list if there is no match. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
sub matching_file_fragment_profile { |
89
|
11
|
|
|
11
|
1
|
1744
|
my $self = shift; |
90
|
11
|
|
|
|
|
14
|
my ($file) = @_; |
91
|
|
|
|
|
|
|
|
92
|
11
|
|
|
|
|
302
|
for my $profile ($self->file_profiles->flatten) { |
93
|
15
|
|
|
|
|
75
|
my ($file_base, $file_fragment) = $profile->matching_file_fragment($file); |
94
|
15
|
100
|
|
|
|
55
|
$file_base and return ($file_base, $file_fragment, $profile); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
3
|
|
|
|
|
13
|
return (); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |