line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Repository::Packages; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
65
|
$CPAN::Repository::Packages::AUTHORITY = 'cpan:GETTY'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$CPAN::Repository::Packages::VERSION = '0.008'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: 02packages |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
9
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with qw( |
13
|
|
|
|
|
|
|
CPAN::Repository::Role::File |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
2403
|
use Dist::Data; |
|
2
|
|
|
|
|
1252197
|
|
|
2
|
|
|
|
|
113
|
|
17
|
2
|
|
|
2
|
|
21
|
use File::Spec::Functions ':ALL'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
530
|
|
18
|
2
|
|
|
2
|
|
13
|
use IO::File; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
341
|
|
19
|
2
|
|
|
2
|
|
2133
|
use DateTime::Format::RFC3339; |
|
2
|
|
|
|
|
2578
|
|
|
2
|
|
|
|
|
75
|
|
20
|
2
|
|
|
2
|
|
16
|
use DateTime::Format::Epoch::Unix; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2509
|
|
21
|
|
|
|
|
|
|
|
22
|
27
|
|
|
27
|
0
|
555
|
sub file_parts { 'modules', '02packages.details.txt' } |
23
|
5
|
|
|
5
|
0
|
78
|
sub file_parts_stamp { 'modules', '02STAMP' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has modules => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
lazy => 1, |
28
|
|
|
|
|
|
|
builder => '_build_modules', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _build_modules { |
32
|
2
|
|
|
2
|
|
447
|
my ( $self ) = @_; |
33
|
2
|
100
|
|
|
|
24
|
return {} unless $self->exist; |
34
|
1
|
|
|
|
|
18
|
my @lines = $self->get_file_lines; |
35
|
1
|
|
|
|
|
1233
|
my %modules; |
36
|
1
|
|
|
|
|
7
|
for (@lines) { |
37
|
11
|
|
|
|
|
14
|
chomp($_); |
38
|
11
|
100
|
|
|
|
45
|
next if ($_ =~ /[^:]:[ \t]/); |
39
|
3
|
100
|
|
|
|
19
|
if ($_ =~ m/^([^ \t]+)[ \t]+([^ \t]+)[ \t]+([^ \t]+)$/) { |
40
|
|
|
|
|
|
|
# $1 = module |
41
|
|
|
|
|
|
|
# $2 = version |
42
|
|
|
|
|
|
|
# $3 = path (inside repository) |
43
|
2
|
|
|
|
|
13
|
$modules{$1} = [ $2, $3 ]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
1
|
|
|
|
|
12
|
return \%modules; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has authorbase_path_parts => ( |
50
|
|
|
|
|
|
|
is => 'ro', |
51
|
|
|
|
|
|
|
required => 1, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has url => ( |
55
|
|
|
|
|
|
|
is => 'ro', |
56
|
|
|
|
|
|
|
required => 1, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has written_by => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
required => 1, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub get_module { |
65
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $module ) = @_; |
66
|
0
|
0
|
|
|
|
0
|
return defined $self->modules->{$module} |
67
|
|
|
|
|
|
|
? $self->modules->{$module}->[1] |
68
|
|
|
|
|
|
|
: (); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_module_version { |
72
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $module ) = @_; |
73
|
0
|
0
|
|
|
|
0
|
return defined $self->modules->{$module} |
74
|
|
|
|
|
|
|
? $self->modules->{$module}->[0] |
75
|
|
|
|
|
|
|
: (); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub set_module { |
79
|
3
|
|
|
3
|
0
|
77
|
my ( $self, $module, $version, $path ) = @_; |
80
|
3
|
|
|
|
|
122
|
return $self->modules->{$module} = [ $version, $path ]; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub add_distribution { |
84
|
3
|
|
|
3
|
0
|
41
|
my ( $self, $author_distribution_path ) = @_; |
85
|
3
|
|
|
|
|
15
|
my $filename = catfile( $self->repository_root, @{$self->authorbase_path_parts}, splitdir( $author_distribution_path ) ); |
|
3
|
|
|
|
|
21
|
|
86
|
3
|
|
|
|
|
100
|
my $dist = Dist::Data->new( $filename ); |
87
|
3
|
|
|
|
|
3921
|
for (keys %{$dist->packages}) { |
|
3
|
|
|
|
|
49
|
|
88
|
3
|
|
|
|
|
1001390
|
$self->set_module($_, $dist->packages->{$_}->{version}, $author_distribution_path); |
89
|
|
|
|
|
|
|
} |
90
|
3
|
|
|
|
|
401
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub stamp_filename { |
94
|
5
|
|
|
5
|
0
|
11
|
my ( $self ) = @_; |
95
|
5
|
|
|
|
|
32
|
catfile( $self->repository_root, $self->file_parts_stamp ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
after save => sub { |
99
|
|
|
|
|
|
|
my ( $self ) = @_; |
100
|
|
|
|
|
|
|
my $stamp = IO::File->new($self->stamp_filename, "w") or die "cant write to ".$self->stamp_filename; |
101
|
|
|
|
|
|
|
my $now = DateTime->now; |
102
|
|
|
|
|
|
|
print $stamp (DateTime::Format::Epoch::Unix->format_datetime($now).' '.DateTime::Format::RFC3339->new->format_datetime($now)."\n"); |
103
|
|
|
|
|
|
|
$stamp->close; |
104
|
|
|
|
|
|
|
}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub timestamp { |
107
|
1
|
|
|
1
|
0
|
13
|
my ( $self ) = @_; |
108
|
1
|
50
|
|
|
|
9
|
my $stamp = IO::File->new($self->stamp_filename, "r") or die "cant read ".$self->stamp_filename; |
109
|
1
|
|
|
|
|
142
|
my ( $line ) = <$stamp>; |
110
|
1
|
|
|
|
|
3
|
chomp($line); |
111
|
1
|
50
|
|
|
|
11
|
if ($line =~ /^(\d+) /) { |
112
|
1
|
|
|
|
|
36
|
return DateTime::Format::Epoch::Unix->parse_datetime($1); |
113
|
|
|
|
|
|
|
} else { |
114
|
0
|
|
|
|
|
0
|
die "cant find unix timestamp from ".$self->stamp_filename; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub generate_content { |
119
|
4
|
|
|
4
|
0
|
12
|
my ( $self ) = @_; |
120
|
4
|
|
|
|
|
17
|
my @file_parts = $self->file_parts; |
121
|
4
|
|
|
|
|
17
|
my $content = ""; |
122
|
4
|
|
|
|
|
26
|
$content .= $self->generate_header_line('File:',(pop @file_parts)); |
123
|
4
|
|
|
|
|
47
|
$content .= $self->generate_header_line('URL:',$self->url.$self->path_inside_root); |
124
|
4
|
|
|
|
|
13
|
$content .= $self->generate_header_line('Description:','Package names found in directory $CPAN/authors/id/'); |
125
|
4
|
|
|
|
|
13
|
$content .= $self->generate_header_line('Columns:','package name, version, path'); |
126
|
4
|
|
|
|
|
19
|
$content .= $self->generate_header_line('Intended-For:','Automated fetch routines, namespace documentation.'); |
127
|
4
|
|
|
|
|
120
|
$content .= $self->generate_header_line('Written-By:',$self->written_by); |
128
|
4
|
|
|
|
|
13
|
$content .= $self->generate_header_line('Line-Count:',scalar keys %{$self->modules}); |
|
4
|
|
|
|
|
91
|
|
129
|
4
|
|
|
|
|
91
|
$content .= $self->generate_header_line('Last-Updated:',DateTime->now->strftime('%a, %e %b %y %T %Z')); |
130
|
4
|
|
|
|
|
49
|
$content .= "\n"; |
131
|
4
|
|
|
|
|
9
|
for (sort { $a cmp $b } keys %{$self->modules}) { |
|
2
|
|
|
|
|
38
|
|
|
4
|
|
|
|
|
118
|
|
132
|
5
|
50
|
|
|
|
199
|
$content .= sprintf("%-60s %-20s %s\n",$_,$self->modules->{$_}->[0] ? $self->modules->{$_}->[0] : 'undef',$self->modules->{$_}->[1]); |
133
|
|
|
|
|
|
|
} |
134
|
4
|
|
|
|
|
263
|
return $content; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub generate_header_line { |
138
|
32
|
|
|
32
|
0
|
3511
|
my ( $self, $key, $value ) = @_; |
139
|
32
|
|
|
|
|
145
|
return sprintf("%-13s %s\n",$key,$value); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |