| 1 | package DMOSS::Report; | ||||||||||
| 2 | # ABSTRACT: DMOSS base class for creating reports | ||||||||||
| 3 | 2 | $DMOSS::Report::VERSION = '0.01_2'; | |||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | my @types = (); | |||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||
| 10 | 1 | my ($class, $dmoss) = @_; | |||||||||
| 11 | 1 | my $self = bless({}, $class); | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | $self->dmoss($dmoss) if $dmoss; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 1 | ▶ | $self->output($self->report) if $dmoss; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | return $self; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | sub dmoss { | ||||||||
|
Subroutine
dmoss: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 20 | 0 | my ($self, $dmoss) = @_; | |||||||||
| 21 | 0 | ▶ | $self->{dmoss} = $dmoss if $dmoss; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | |||||||||||
| 23 | 0 | return $self->{dmoss}; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub output { | ||||||||
|
Subroutine
output: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 27 | 0 | my ($self, $output) = @_; | |||||||||
| 28 | 0 | ▶ | $self->{output} = $output if $output; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | |||||||||||
| 30 | 0 | return $self->{output}; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub report { | ||||||||
|
Subroutine
report: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 34 | 0 | my ($self) = (@_); | |||||||||
| 35 | 0 | my $output = ''; | |||||||||
| 36 | |||||||||||
| 37 | # begin report | ||||||||||
| 38 | 0 | $output .= $self->start_report; | |||||||||
| 39 | |||||||||||
| 40 | # include plugins reports | ||||||||||
| 41 | 0 | foreach my $p (sort @{ $self->dmoss->{plugins} }) { | |||||||||
| 42 | 0 | my $plugin; | |||||||||
| 43 | |||||||||||
| 44 | # include title, and grade | ||||||||||
| 45 | 0 | my $grade = $self->grade( $self->dmoss->plugin_grade($p) ); | |||||||||
| 46 | 0 | $plugin .= $self->make_title($p, $grade); | |||||||||
| 47 | |||||||||||
| 48 | # include a row for every attribute | ||||||||||
| 49 | 0 | my @reports = $self->dmoss->report_attrs_plugin($self, $p); | |||||||||
| 50 | #use Data::Dumper; print STDERR Dumper(@reports); | ||||||||||
| 51 | 0 | my @results; | |||||||||
| 52 | 0 | foreach (@reports) { | |||||||||
| 53 | 0 | ▶ | if (ref $_ eq 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | ▶ | push @results, $self->make_row(@$_) if (scalar(@$_) > 0); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | } | ||||||||||
| 56 | else { | ||||||||||
| 57 | 0 | push @results, $_; | |||||||||
| 58 | } | ||||||||||
| 59 | } | ||||||||||
| 60 | 0 | $plugin .= $self->make_more_info($p, @results); | |||||||||
| 61 | |||||||||||
| 62 | 0 | $output .= $self->make_plugin_box($plugin, $grade); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | # end report | ||||||||||
| 66 | 0 | $output .= $self->end_report; | |||||||||
| 67 | |||||||||||
| 68 | 0 | return $output; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | sub make_title { | ||||||||
|
Subroutine
make_title: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 72 | 0 | my ($self, $plugin, $grade) = (@_); | |||||||||
| 73 | |||||||||||
| 74 | 0 | return "$plugin == $grade\n"; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub make_plugin_box { | ||||||||
|
Subroutine
make_plugin_box: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 78 | 0 | my ($self, $content) = (@_); | |||||||||
| 79 | |||||||||||
| 80 | 0 | return(('-'x60)."+\n$content\n"); | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 0 | ▶ | sub make_more_info { | ||||||||
|
Subroutine
make_more_info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 84 | 0 | my ($self, $plugin, @results) = (@_); | |||||||||
| 85 | |||||||||||
| 86 | 0 | return(join("\n", @results)); | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | sub make_row { | ||||||||
|
Subroutine
make_row: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 90 | 0 | my ($self, @values) = (@_); | |||||||||
| 91 | |||||||||||
| 92 | 0 | return join("\t\t", @values); | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 0 | ▶ | sub grade { | ||||||||
|
Subroutine
grade: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 96 | 0 | my ($self, $num) = (@_); | |||||||||
| 97 | |||||||||||
| 98 | 0 | ▶ | return 'F' if $num < 0.1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 0 | ▶ | return 'D' if $num < 0.4; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | 0 | ▶ | return 'C' if $num < 0.6; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | 0 | ▶ | return 'B' if $num < 0.8; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | 0 | return 'A'; | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | sub start_report { "\nDMOSS Report\n" } | ||||||||
|
Subroutine
start_report: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 106 | |||||||||||
| 107 | 0 | ▶ | sub end_report { "\n" } | ||||||||
|
Subroutine
end_report: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 108 | |||||||||||
| 109 | 2 | 1; | |||||||||
| 110 | |||||||||||
| 111 | __END__ | ||||||||||