| 1 | package DMOSS::Plugin::VerifyLicense; | ||||||||||
| 2 | 1 | $DMOSS::Plugin::VerifyLicense::VERSION = '0.01_2'; | |||||||||
| 3 | # ABSTRACT: DMOSS fix me description | ||||||||||
| 4 | 1 | ▶ | use parent qw/DMOSS::Plugin/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Software::License; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Software::LicenseUtils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use File::Slurp qw/read_file/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | our @types = qw/README LICENSE/; | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub name { 'Verify License' } | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | sub process { | ||||||||
|
Subroutine
process: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 18 | 0 | my ($self, $dmoss, $file) = @_; | |||||||||
| 19 | 0 | my $content = read_file $file->fullpath; | |||||||||
| 20 | 0 | ▶ | return unless $content =~ m/\b(licen[cs]e|licensing|copyright|legal)\b/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | # guess license | ||||||||||
| 23 | 0 | $content = "=head1 license\n" . $content . "\n=cut"; | |||||||||
| 24 | 0 | my @guesses = Software::LicenseUtils->guess_license_from_pod($content); | |||||||||
| 25 | 0 | my $top = shift @guesses; | |||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | if ($top) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | my $license = $top->name; | |||||||||
| 29 | 0 | $dmoss->add_attr('license', $license); | |||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub reduce { | ||||||||
|
Subroutine
reduce: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 34 | 0 | my ($self, $dmoss, @attrs) = @_; | |||||||||
| 35 | 0 | ▶ | return unless @attrs; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | if (@attrs > 1) { # more than one license was found | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | # FIXME | ||||||||||
| 39 | } | ||||||||||
| 40 | else { | ||||||||||
| 41 | 0 | $dmoss->add_attr('license', $attrs[0]->value); | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub report { | ||||||||
|
Subroutine
report: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 46 | 0 | my ($self, $dmoss, $attr) = @_; | |||||||||
| 47 | |||||||||||
| 48 | 0 | return [ $attr->file->{path}, $attr->value ]; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub report_headers { | ||||||||
|
Subroutine
report_headers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 52 | 0 | my ($self, $dmoss) = @_; | |||||||||
| 53 | |||||||||||
| 54 | 0 | return [ 'File', 'License' ]; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub grade { | ||||||||
|
Subroutine
grade: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 58 | 0 | my ($self, $dmoss, $attr) = @_; | |||||||||
| 59 | 0 | ▶ | return 0 unless $attr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | return ( $attr->value ? 1 : 0 ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 1 | 1; | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||