lib/MARC/Record/Stats/Report.pm

filter: Statementstmt 23.3% 7 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 25.0% 10 / 40 CC 6 SCAR 34.6
CC
6
Cov
19%
report
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 31.8
↑ Summary lib/MARC/Record/Stats.pm »
1 package MARC::Record::Stats::Report;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 MARC::Record::Stats::Report - report generator for MARC::Record::Stats
9  
10 =head1 SYNOPSIS
11  
12 See SYNOPSIS and report method in L<MARC::Record::Stats>
13  
14 =head1 METHODS
15  
16 =head2 report $fh, $stats, $config?
17  
18 Prints out to a filehandle $fh a report on statistics
19 collected in $stats (L<MARC::Record::Stats>),
20 using options from $config, which is a HASHREF with keys:
21  
22 =over
23  
24 =item dots => [undef|0|1]
25  
26 Replace spaces with dots if dots => 1 for readability. Table will look like:
27  
28 955..............86.67
29 ...a.............86.67
30 ...e.............20.00
31 ...t.............46.67
32  
33 =back
34  
35 =cut
36  
37 0 ▶sub report{
Subroutine report: not called CC=6 SCAR=37.4
Pod documented
38 0 my ($self, $FH, $stats, $config) = @_;
39
40 0 my $hash = $stats->get_stats_hash;
41
42 0 my @lines;
43 0 my $nrecords = $hash->{nrecords};
44
45 0 foreach my $tag ( sort keys %{$hash->{tags}} ) {
46 0 my $tagstat = $hash->{tags}->{$tag};
47 0 ▶ my $is_repeatable = $tagstat->{repeatable} ? '[Y]' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
$tagstat->{'repeatable'} ? : 0 0 0
48 0 my $occurence = sprintf("%6.2f",100*$tagstat->{occurence}/$nrecords);
49 0 push @lines, "$tag $is_repeatable $occurence";
50
51 0 foreach my $subtag ( sort keys %{ $tagstat->{subtags} } ) {
52 0 my $subtagstat = $tagstat->{subtags}->{$subtag};
53 0 my $occurence = sprintf("%6.2f",100.0*$subtagstat->{occurence}/$nrecords);
54 0 ▶ my $is_repeatable = $tagstat->{repeatable} ? '[Y]' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
$tagstat->{'repeatable'} ? : 0 0 0
55 0 push @lines, " $subtag $is_repeatable $occurence";
56 }
57
58 }
59
60 0 ▶ if ( $config->{'dots'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"dots"}) 0 0 0
61 0 @lines = map { s/\s/./g; $_ } @lines;
62 }
63
64 0 unshift @lines, "Tag Rep. Occ.,%";
65 0 unshift @lines, "Statistics for $nrecords records";
66
67
68
69 0 print $FH join ("\n",@lines), qq{\n\n};
70
71 }
72  
73  
74 =head1 AUTHOR
75  
76 Andrei V. Toutoukine, C<< <tut at isuct.ru> >>
77  
78 =head1 BUGS
79  
80 Please report any bugs or feature requests to C<bug-/home/tut/bin/src/marc-record-stats at rt.cpan.org>, or through
81 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=/home/tut/bin/src/MARC-Record-Stats>. I will be notified, and then you'll
82 automatically be notified of progress on your bug as I make changes.
83  
84  
85  
86  
87 =head1 SUPPORT
88  
89 You can find documentation for this module with the perldoc command.
90  
91 perldoc MARC::Record::Stats::Report
92  
93  
94 You can also look for information at:
95  
96 =over 4
97  
98 =item * RT: CPAN's request tracker
99  
100 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=/home/tut/bin/src/MARC-Record-Stats>
101  
102 =item * AnnoCPAN: Annotated CPAN documentation
103  
104 L<http://annocpan.org/dist//home/tut/bin/src/MARC-Record-Stats>
105  
106 =item * CPAN Ratings
107  
108 L<http://cpanratings.perl.org/d//home/tut/bin/src/MARC-Record-Stats>
109  
110 =item * Search CPAN
111  
112 L<http://search.cpan.org/dist//home/tut/bin/src/MARC-Record-Stats/>
113  
114 =back
115  
116  
117 =head1 ACKNOWLEDGEMENTS
118  
119  
120 =head1 LICENSE AND COPYRIGHT
121  
122 Copyright 2011 Andrei V. Toutoukine.
123  
124 This program is free software; you can redistribute it and/or modify it
125 under the terms of either: the GNU General Public License as published
126 by the Free Software Foundation; or the Artistic License.
127  
128 See http://dev.perl.org/licenses/ for more information.
129  
130  
131 =cut
132  
133 3 1; # End of MARC::Record::Stats::Report
↑ Summary lib/MARC/Record/Stats.pm »