| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Debian::Control::Stanza::CommaSeparated; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Debian::Control::Stanza::CommaSeparated - comma separated debian/control field abstraction |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
|
8
|
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
34914995
|
use strict; |
|
|
9
|
|
|
|
|
25
|
|
|
|
9
|
|
|
|
|
367
|
|
|
10
|
9
|
|
|
9
|
|
51
|
use warnings; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
648
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.66'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
9
|
|
|
9
|
|
7486
|
use Array::Unique; |
|
|
9
|
|
|
|
|
9108
|
|
|
|
9
|
|
|
|
|
264
|
|
|
15
|
9
|
|
|
9
|
|
8177
|
use Text::ParseWords qw(quotewords); |
|
|
9
|
|
|
|
|
13851
|
|
|
|
9
|
|
|
|
|
990
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
9
|
|
|
9
|
|
63
|
use overload '""' => \&as_string; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
229
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $f = Debian::Control::Stanza::CommaSeparated->new( |
|
22
|
|
|
|
|
|
|
'Joe M '); |
|
23
|
|
|
|
|
|
|
$f->add('"Smith, Agent" , Joe M '); |
|
24
|
|
|
|
|
|
|
print $f->as_string; |
|
25
|
|
|
|
|
|
|
# 'Joe M , "Smith, Agent" ' |
|
26
|
|
|
|
|
|
|
print "$f"; # the same |
|
27
|
|
|
|
|
|
|
$f->sort; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Debian::Control::Stanza::CommaSeparated abstracts handling of comma-separated |
|
32
|
|
|
|
|
|
|
list of values, often found in F file fields like I. |
|
33
|
|
|
|
|
|
|
Note that the various dependency fields in F also use |
|
34
|
|
|
|
|
|
|
comma-separated values, but the L class is more suitable |
|
35
|
|
|
|
|
|
|
for these as it is for example also capable of finding overlapping dependency |
|
36
|
|
|
|
|
|
|
declarations. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item new (initial values) |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The initial values list is parsed and may contain strings that are in fact |
|
45
|
|
|
|
|
|
|
comma-separated lists. These are split appropriately using L' |
|
46
|
|
|
|
|
|
|
I routine. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=back |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
|
53
|
1
|
|
|
1
|
1
|
19
|
my $self = bless [], shift; |
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
46
|
tie @$self, 'Array::Unique'; |
|
56
|
|
|
|
|
|
|
|
|
57
|
1
|
50
|
|
|
|
15
|
$self->add(@_) if @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
64
|
$self; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item as_string |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns text representation of the list. A simple join of the elements by C<, >. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The same function is used for overloading the stringification operation. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub as_string |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
1
|
|
|
1
|
1
|
939
|
return join( ', ', @{ $_[0] } ); |
|
|
1
|
|
|
|
|
4
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _parse { |
|
80
|
3
|
|
|
3
|
|
4
|
my $self = shift; |
|
81
|
|
|
|
|
|
|
|
|
82
|
3
|
|
|
|
|
4
|
my @output; |
|
83
|
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
7
|
for (@_) { |
|
85
|
3
|
|
|
|
|
19
|
my @items = quotewords( qr/\s*,\s*/, 1, $_ ); |
|
86
|
3
|
|
|
|
|
377
|
push @output, @items; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
3
|
|
|
|
|
13
|
return @output; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item add I<@items> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Adds the given items to the list. Items that are already present are not added, |
|
95
|
|
|
|
|
|
|
keeping the list unique. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub add { |
|
100
|
3
|
|
|
3
|
1
|
1577
|
my ( $self, @items ) = @_; |
|
101
|
|
|
|
|
|
|
|
|
102
|
3
|
|
|
|
|
10
|
push @$self, $self->_parse(@items); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item sort |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
A handy method for sorting the list. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub sort { |
|
112
|
1
|
|
|
1
|
1
|
1484
|
my $self = shift; |
|
113
|
|
|
|
|
|
|
|
|
114
|
1
|
|
|
|
|
4
|
@$self = sort @$self; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |