line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Book::Collate::Writer::Report; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
409
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Book::Collate::Writer::Report |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.0.1 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = 'v0.0.1'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Given a file name, a report directory name, and a data object that includes report data, |
23
|
|
|
|
|
|
|
writes the report. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 EXPORT |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
A list of functions that can be exported. You can delete this section |
29
|
|
|
|
|
|
|
if you don't export anything, such as for a purely object-oriented module. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 write_report_book |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Takes a book object, iterates through the sections, and writes the reports. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub write_report_book { |
40
|
0
|
|
|
0
|
1
|
|
my ($self, $book) = @_; |
41
|
|
|
|
|
|
|
# This assumes it is given a book object, which has section objects. |
42
|
0
|
|
|
|
|
|
foreach my $section ( @{$book->sections()} ){ |
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $report_file = $book->report_dir . "/report_" . $section->filename(); |
44
|
0
|
0
|
|
|
|
|
open( my $file, '>', $report_file ) or die "Can't open $report_file: $!"; |
45
|
0
|
|
|
|
|
|
print $file write_report_section($section); |
46
|
0
|
|
|
|
|
|
close($file); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 write_report_section |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Takes a section object and returns the stringified report. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub write_report_section { |
58
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $string = "Grade Level: " . $self->grade_level() . "\n"; |
60
|
0
|
|
|
|
|
|
$string .= "Average Word Length: " . $self->avg_word_length() . "\n"; |
61
|
0
|
|
|
|
|
|
$string .= "Average Sentence Length " . $self->avg_sentence_length() . "\n"; |
62
|
0
|
|
|
|
|
|
$string .= "Word Frequency List:\n"; |
63
|
0
|
|
|
|
|
|
my %word_list = $self->{_report}->sorted_word_list(); |
64
|
0
|
|
|
|
|
|
my @unsorted_keys = ( keys %word_list ); |
65
|
0
|
|
|
|
|
|
my @sorted_keys = reverse ( sort { $a <=> $b } @unsorted_keys ); |
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $max_keys = 25; |
67
|
0
|
|
|
|
|
|
foreach my $count ( @sorted_keys ){ |
68
|
0
|
|
|
|
|
|
$string .= " $count "; |
69
|
0
|
|
|
|
|
|
foreach my $word ( @{$word_list{$count}} ){ |
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$string .= " $word"; |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
|
$string .= "\n"; |
73
|
0
|
|
|
|
|
|
$max_keys -= 1; |
74
|
0
|
0
|
|
|
|
|
last unless $max_keys; |
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
|
|
|
|
return $string; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Leam Hall, C<< >> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 BUGS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
86
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
87
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SUPPORT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
perldoc Book::Collate::Writer::Report |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
You can also look for information at: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over 4 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * CPAN Ratings |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * Search CPAN |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This software is Copyright (c) 2021 by Leam Hall. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This is free software, licensed under: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; # End of Book::Collate::Writer::Report |