| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MyCPAN::Indexer::Reporter::AsYAML; |
|
2
|
1
|
|
|
1
|
|
1182
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
43
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use parent qw(MyCPAN::Indexer::Reporter::Base); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
1
|
|
|
1
|
|
41
|
use vars qw($VERSION $logger); |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
52
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '1.28_12'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
159
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use File::Basename; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
61
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use File::Path qw(make_path); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
49
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use File::Spec::Functions qw(catfile); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
43
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use Log::Log4perl; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
14
|
1
|
|
|
1
|
|
832
|
use Clone qw(clone); |
|
|
1
|
|
|
|
|
3537
|
|
|
|
1
|
|
|
|
|
69
|
|
|
15
|
1
|
|
|
1
|
|
807
|
use YAML::Syck qw(Dump); |
|
|
1
|
|
|
|
|
2326
|
|
|
|
1
|
|
|
|
|
97
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN { |
|
18
|
1
|
|
|
1
|
|
11
|
$logger = Log::Log4perl->get_logger( 'Reporter' ); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
MyCPAN::Indexer::Reporter::AsYAML - Save the result as a YAML file |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Use this in backpan_indexer.pl by specifying it as the reporter class: |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# in backpan_indexer.config |
|
30
|
|
|
|
|
|
|
reporter_class MyCPAN::Indexer::Reporter::AsYAML |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This class takes the result of examining a distribution and saves it. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 Methods |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over 4 |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item get_reporter( $Notes ) |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
C sets the C key in the C<$Notes> hash reference. The |
|
43
|
|
|
|
|
|
|
value is a code reference that takes the information collected about a distribution |
|
44
|
|
|
|
|
|
|
and dumps it as a YAML file. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
See L for details about what C expects |
|
47
|
|
|
|
|
|
|
and should do. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_reporter |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
|
|
|
|
|
|
#TRACE( sub { get_caller_info } ); |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $reporter = sub { |
|
58
|
0
|
|
|
0
|
|
|
my( $info ) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
unless( defined $info ) |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
0
|
|
|
|
|
|
$logger->error( "info is undefined!" ); |
|
63
|
0
|
|
|
|
|
|
return; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $out_path = $self->get_report_path( $info ); |
|
67
|
0
|
|
|
|
|
|
my $dir = dirname( $out_path ); |
|
68
|
0
|
0
|
|
|
|
|
unless( -d $dir ) |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
0
|
0
|
|
|
|
|
make_path( $dir ) or |
|
71
|
|
|
|
|
|
|
$logger->fatal( "Could not create directory $dir: $!" ); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
open my($fh), ">:utf8", $out_path or |
|
75
|
|
|
|
|
|
|
$logger->fatal( "Could not open $out_path: $!" ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
{ |
|
78
|
|
|
|
|
|
|
# now that indexer is a component, it has references to all the other |
|
79
|
|
|
|
|
|
|
# objects, making for a big dump. We don't want the keys starting |
|
80
|
|
|
|
|
|
|
# with _ |
|
81
|
|
|
|
|
|
|
# Storable doesn't work because it can't handle the CODE refs |
|
82
|
0
|
|
|
|
|
|
my $clone = clone( $info ); # hack until we get an info class |
|
|
0
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $dist = $clone->{dist_info}{dist_basename}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
|
86
|
0
|
|
|
|
|
|
$logger->warn( "Error writing to YAML output for $dist: @_" ); |
|
87
|
0
|
|
|
|
|
|
}; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
foreach my $key ( keys %$clone ) { |
|
90
|
0
|
0
|
|
|
|
|
delete $clone->{$key} if $key =~ /^_/; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
print $fh Dump( $clone ); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
0
|
0
|
|
|
|
|
$logger->error( "$out_path is missing!" ) unless -e $out_path; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
1; |
|
98
|
0
|
|
|
|
|
|
}; |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->set_note( 'reporter', $reporter ); |
|
101
|
0
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item get_report_file_extension |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the extension for reports from this reporter. Since we're making |
|
107
|
|
|
|
|
|
|
YAML files, that's C. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
0
|
1
|
|
sub get_report_file_extension { 'yml' } |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 TO DO |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This code is in Github: |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
git://github.com/briandfoy/mycpan-indexer.git |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
brian d foy, C<< >> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (c) 2008-2013, brian d foy, All Rights Reserved. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
You may redistribute this under the same terms as Perl itself. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |