Role/DetermineRightsFromRdf.pm

filter: Statementstmt 75.9% 41 / 54 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod n/a totaltotal 68.0% 51 / 75 CC 6 SCAR 28.0
CC
6
Cov
64%
_determine_rights_from_rdf
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 16.4
« Role/WriteDOAP.pm ↑ Summary Role/WriteChanges.pm »
1 package Dist::Inkt::Role::DetermineRightsFromRdf;
2  
3 1 our $AUTHORITY = 'cpan:TOBYINK';
4 1 our $VERSION = '0.110';
5  
6 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use RDF::Trine qw( iri literal statement variable );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use List::Util qw( uniq );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Path::Tiny qw( path );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Path::Iterator::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Software::License;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Software::LicenseUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 my %URIS = (
17 'http://www.gnu.org/licenses/agpl-3.0.txt' => 'AGPL_3',
18 'http://www.apache.org/licenses/LICENSE-1.1' => 'Apache_1_1',
19 'http://www.apache.org/licenses/LICENSE-2.0' => 'Apache_2_0',
20 'http://www.apache.org/licenses/LICENSE-2.0.txt' => 'Apache_2_0',
21 'http://www.perlfoundation.org/artistic_license_1_0' => 'Artistic_1_0',
22 'http://opensource.org/licenses/artistic-license.php' => 'Artistic_1_0',
23 'http://www.perlfoundation.org/artistic_license_2_0' => 'Artistic_2_0',
24 'http://opensource.org/licenses/artistic-license-2.0.php' => 'Artistic_2_0',
25 'http://www.opensource.org/licenses/bsd-license.php' => 'BSD',
26 'http://creativecommons.org/publicdomain/zero/1.0/' => 'CC0_1_0',
27 'http://www.freebsd.org/copyright/freebsd-license.html' => 'FreeBSD',
28 'http://www.gnu.org/copyleft/fdl.html' => 'GFDL_1_3',
29 'http://www.opensource.org/licenses/gpl-license.php' => 'GPL_1',
30 'http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt' => 'GPL_1',
31 'http://www.opensource.org/licenses/gpl-2.0.php' => 'GPL_2',
32 'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt' => 'GPL_2',
33 'http://www.opensource.org/licenses/gpl-3.0.html' => 'GPL_3',
34 'http://www.gnu.org/licenses/gpl-3.0.txt' => 'GPL_3',
35 'http://www.opensource.org/licenses/lgpl-2.1.php' => 'LGPL_2_1',
36 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt' => 'LGPL_2_1',
37 'http://www.opensource.org/licenses/lgpl-3.0.html' => 'LGPL_3_0',
38 'http://www.gnu.org/licenses/lgpl-3.0.txt' => 'LGPL_3_0',
39 'http://www.opensource.org/licenses/mit-license.php' => 'MIT',
40 'http://www.mozilla.org/MPL/MPL-1.0.txt' => 'Mozilla_1_0',
41 'http://www.mozilla.org/MPL/MPL-1.1.txt' => 'Mozilla_1_1',
42 'http://opensource.org/licenses/mozilla1.1.php' => 'Mozilla_1_1',
43 'http://www.openssl.org/source/license.html' => 'OpenSSL',
44 'http://dev.perl.org/licenses/' => 'Perl_5',
45 'http://www.opensource.org/licenses/postgresql' => 'PostgreSQL',
46 'http://trolltech.com/products/qt/licenses/licensing/qpl' => 'QPL_1_0',
47 'http://h71000.www7.hp.com/doc/83final/BA554_90007/apcs02.html' => 'SSLeay',
48 'http://www.openoffice.org/licenses/sissl_license.html' => 'Sun',
49 'http://www.zlib.net/zlib_license.html' => 'Zlib',
50 );
51 1 eval("require Software::License::$_") for uniq values %URIS;
52  
53 1 ▶use RDF::Trine::Namespace qw[RDF RDFS OWL XSD];
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 my $CPAN = RDF::Trine::Namespace->new('http://purl.org/NET/cpan-uri/terms#');
55 1 my $DC = RDF::Trine::Namespace->new('http://purl.org/dc/terms/');
56 1 my $DOAP = RDF::Trine::Namespace->new('http://usefulinc.com/ns/doap#');
57 1 my $FOAF = RDF::Trine::Namespace->new('http://xmlns.com/foaf/0.1/');
58 1 my $NFO = RDF::Trine::Namespace->new('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#');
59 1 my $SKOS = RDF::Trine::Namespace->new('http://www.w3.org/2004/02/skos/core#');
60  
61 sub _determine_rights_from_rdf
62 0 ▶{
Subroutine _determine_rights_from_rdf: not called CC=6 SCAR=37.4
63 0 my ($self, $f) = @_;
64 0 ▶ unless ($self->{_rdf_copyright_data})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_rdf_copyright_data"}) 0 0 0
65 {
66 0 my $model = $self->model;
67 0 my $iter = $model->get_pattern(
68 RDF::Trine::Pattern->new(
69 statement(variable('subject'), $NFO->fileName, variable('filename')),
70 statement(variable('subject'), $DC->license, variable('license')),
71 statement(variable('subject'), $DC->rightsHolder, variable('rights_holder')),
72 statement(variable('rights_holder'), $FOAF->name, variable('name')),
73 ),
74 );
75 0 my %results;
76 0 ▶ while (my $row = $iter->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $iter->next) 0 0 0
77 0 my $l = $row->{license}->uri;
78 $row->{class} = literal("Software::License::$URIS{$l}")
79 0 ▶ if exists $URIS{$l};
Branch: 1 branch
BranchTrueFalseTotal
if exists $URIS{$l} 0 0 0
80 0 $results{ $row->{filename}->literal_value } = $row;
81 }
82 0 $self->{_rdf_copyright_data} = \%results;
83 }
84
85 0 ▶ if ( my $row = $self->{_rdf_copyright_data}{$f} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $self->{"_rdf_copyright_data"}{$f}) 0 0 0
86 return (
87 sprintf("Copyright %d %s.", 1900 + (localtime((stat $f)[9]))[5], $row->{name}->literal_value),
88 $row->{class}->literal_value->new({holder => "the copyright holder(s)"}),
89 0 ▶ ) if $row->{class};
Branch: 1 branch
BranchTrueFalseTotal
if $row->{"class"} 0 0 0
90 }
91
92 0 return;
93 }
94  
95 1 1;
« Role/WriteDOAP.pm ↑ Summary Role/WriteChanges.pm »