line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
872
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
2
|
|
|
|
|
|
|
package Parse::CVSEntries; |
3
|
1
|
|
|
1
|
|
7
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
214
|
|
4
|
|
|
|
|
|
|
$VERSION = '0.03'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Parse::CVSEntries - parse a CVS/Entries file |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $parsed = Parse::CVSEntries->new( 'CVS/Entries' ); |
13
|
|
|
|
|
|
|
for my $entry ($parsed->entries) { |
14
|
|
|
|
|
|
|
print $entry->name, " ", $entry->version, "\n"; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 new( $file ) |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Opens a file and parses it invoking C<< entry_class->new >> to |
26
|
|
|
|
|
|
|
actually prepare the data. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
31
|
3
|
|
|
3
|
1
|
346
|
my $class = shift; |
32
|
3
|
|
|
|
|
5
|
my $filename = shift; |
33
|
3
|
100
|
|
|
|
159
|
open my $fh, "<$filename" or return; |
34
|
2
|
|
|
|
|
46
|
my @entries = map { chomp; $class->entry_class->new($_) } <$fh>; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
41
|
|
35
|
2
|
|
|
|
|
41
|
bless \@entries, $class; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 entries |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns a list of all the entries in the parsed file. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub entries { |
45
|
3
|
|
|
3
|
1
|
1550
|
@{ $_[0] } |
|
3
|
|
|
|
|
15
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 entry_class |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
What class to instantiate for each entry. Defaults to C |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub entry_class { |
55
|
15
|
|
|
15
|
1
|
40
|
'Parse::CVSEntry'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 Parse::CVSEntry |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
A representation of an entry in the entries file. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
All of these are just simple data accessors. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 dir |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 name |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 version |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 modified |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 mtime |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
C as epoch seconds |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
package Parse::CVSEntry; |
81
|
1
|
|
|
1
|
|
878
|
use Class::Accessor::Fast; |
|
1
|
|
|
|
|
3434
|
|
|
1
|
|
|
|
|
9
|
|
82
|
1
|
|
|
1
|
|
26
|
use base 'Class::Accessor::Fast'; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
62
|
|
83
|
1
|
|
|
1
|
|
763
|
use Date::Parse qw( str2time ); |
|
1
|
|
|
|
|
8745
|
|
|
1
|
|
|
|
|
278
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# the actual fields in the file |
86
|
|
|
|
|
|
|
my @fields = qw( dir name version modified bar baz ); |
87
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( @fields, qw( mtime ) ); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub new { |
90
|
15
|
|
|
15
|
|
19
|
my $class = shift; |
91
|
15
|
|
|
|
|
17
|
my $line = shift; |
92
|
|
|
|
|
|
|
|
93
|
15
|
|
|
|
|
18
|
my %self; |
94
|
15
|
|
|
|
|
95
|
@self{ @fields } = split /\//, $_; |
95
|
15
|
|
|
|
|
65
|
my $new = $class->SUPER::new(\%self); |
96
|
|
|
|
|
|
|
|
97
|
15
|
|
|
|
|
187
|
$new->mtime( str2time $new->modified, "UTC" ); |
98
|
15
|
|
|
|
|
3620
|
return $new; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
__END__ |