Toby Inkster avatar Toby Inkster committed 401bdcc

rdf stuff

Comments (0)

Files changed (3)

examples/example-output.txt

+
+Files: COPYRIGHT
+Copyright: None
+License: public-domain
+Comment: This file! Automatically generated.
+
+Files: META.yml
+Copyright: None
+License: public-domain
+Comment: Automatically generated metadata.
+
+Files: inc/Module/Install.pm
+Copyright: Copyright 2002 - 2012 Brian Ingerson, Audrey Tang and Adam Kennedy.
+License: Artistic or GPL-1+
+
+Files: inc/Module/Install/Base.pm
+Copyright: Copyright 2003, 2004 by Audrey Tang <autrijus@autrijus.org>.
+License: GPL-1.0+ or Artistic-1.0
+
+Files: inc/Module/Install/Include.pm
+Copyright: Copyright 2002 - 2012 Brian Ingerson, Audrey Tang and Adam Kennedy.
+License: Artistic or GPL-1+
+
+Files: inc/Module/Install/Makefile.pm
+Copyright: Copyright 2002, 2003, 2004 Audrey Tang and Brian Ingerson.
+License: GPL-1.0+ or Artistic-1.0
+
+Files: inc/Module/Install/Metadata.pm
+Copyright: Copyright 2002 - 2012 Brian Ingerson, Audrey Tang and Adam Kennedy.
+License: Artistic or GPL-1+
+
+Files: inc/Module/Install/Package.pm
+Copyright: Copyright (c) 2011. Ingy doet Net.
+License: Artistic or GPL-1+
+
+Files: inc/Module/Install/TrustMetaYml.pm
+Copyright: This software is copyright (c) 2011-2012 by Toby Inkster.
+License: GPL-1.0+ or Artistic-1.0
+
+Files: inc/Scalar/Util.pm
+Copyright: Copyright (c) 1997-2007 Graham Barr <gbarr@pobox.com>. All rights reserved. Copyright (c) 1999 Tuomas J. Lukka <lukka@iki.fi>. All rights reserved.
+License: GPL-1.0+ or Artistic-1.0
+
+Files: inc/YAML/Tiny.pm
+Copyright: Copyright 2006 - 2012 Adam Kennedy.
+License: GPL-1.0+ or Artistic-1.0
+
+Files: inc/unicore/Name.pm
+Copyright: 1993-2012, Larry Wall and others
+License: Artistic or GPL-1+
+
+Files: inc/utf8.pm
+Copyright: 1993-2012, Larry Wall and others
+License: Artistic or GPL-1+
+
+Files: lib/Module/Install/Copyright.pm
+Copyright: This software is copyright (c) 2012 by Toby Inkster.
+License: GPL-1.0+ or Artistic-1.0
+
+Files: meta/changes.pret
+Copyright: Copyright 2012 Toby Inkster.
+License: GPL-1.0+ or Artistic-1.0
+
+Files: Changes HACKING.pod LICENSE MANIFEST.SKIP Makefile.PL README inc/Module/Package/Dist/RDF.pm lib/Module/Install/Admin/Copyright.pm meta/copyrights.pret meta/doap.pret meta/makefile.pret meta/people.pret t/01basic.t
+Copyright: Unknown
+License: Unknown

lib/Module/Install/Admin/Copyright.pm

 use Module::Install::Admin::RDF 0.003;
 use Module::Manifest;
 use List::MoreUtils qw( uniq );
-use RDF::Trine qw( iri literal statement );
+use RDF::Trine qw( iri literal statement variable );
 use Software::License;
 use Software::LicenseUtils;
 use Path::Class qw( file dir );
 
 sub write_copyright_file
 {
-	my $self  = shift;	
+	my $self = shift;	
+	$self->_debian_copyright->write('COPYRIGHT');
+	$self->clean_files('COPYRIGHT');
+}
+
+sub _debian_copyright
+{
+	my $self = shift;
+	return $self->{_debian_copyright} if defined $self->{_debian_copyright};
+	
 	my @files = uniq COPYRIGHT => sort $self->_get_dist_files;
 	
 	my $c = 'Debian::Copyright'->new;
 		$c->files->Push($stanza->Files => $stanza);
 	}
 
-	$c->write('COPYRIGHT');
-	$self->clean_files('COPYRIGHT');
+	$self->{_debian_copyright} = $c;
 }
 
 sub _get_dist_files
 	return;
 }
 
+my %DEB = qw(
+	Software::License::AGPL_3
+	Software::License::Apache_1_1     Apache-1.1
+	Software::License::Apache_2_0     Apache-2.0
+	Software::License::Artistic_1_0   Artistic-1.0
+	Software::License::Artistic_2_0   Artistic-2.0
+	Software::License::BSD            BSD-3-clause
+	Software::License::CC0_1_0        CC0
+	Software::License::GFDL_1_2       GFDL-1.2
+	Software::License::GFDL_1_3       GFDL-1.3
+	Software::License::GPL_1          GPL-1.0
+	Software::License::GPL_2          GPL-2.0
+	Software::License::GPL_3          GPL-3.0
+	Software::License::LGPL_2_1       LGPL-2.1
+	Software::License::LGPL_3_0       GPL-3.0
+	Software::License::MIT            Expat
+	Software::License::Mozilla_1_0    MPL-1.0
+	Software::License::Mozilla_1_1    MPL-1.1
+	Software::License::QPL_1_0        QPL-1.0
+	Software::License::Zlib           Zlib
+);
+$DEB{"Software::License::Perl_5"} = "GPL-1.0+ or Artistic-1.0";
+
+sub _SL
+{
+	$DEB{ ref($_[0]) || $_[0] };
+}
+
+my %URIS = (
+	'http://www.gnu.org/licenses/agpl-3.0.txt'              => 'AGPL_3',
+	'http://www.apache.org/licenses/LICENSE-1.1'            => 'Apache_1_1',
+	'http://www.apache.org/licenses/LICENSE-2.0'            => 'Apache_2_0',
+	'http://www.apache.org/licenses/LICENSE-2.0.txt'        => 'Apache_2_0',
+	'http://www.perlfoundation.org/artistic_license_1_0'    => 'Artistic_1_0',
+	'http://opensource.org/licenses/artistic-license.php'   => 'Artistic_1_0',
+	'http://www.perlfoundation.org/artistic_license_2_0'    => 'Artistic_2_0',
+	'http://opensource.org/licenses/artistic-license-2.0.php'  => 'Artistic_2_0',
+	'http://www.opensource.org/licenses/bsd-license.php'    => 'BSD',
+	'http://creativecommons.org/publicdomain/zero/1.0/'     => 'CC0_1_0',
+	'http://www.freebsd.org/copyright/freebsd-license.html' => 'FreeBSD',
+	'http://www.gnu.org/copyleft/fdl.html'                  => 'GFDL_1_3',
+	'http://www.opensource.org/licenses/gpl-license.php'    => 'GPL_1',
+	'http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt'  => 'GPL_1',
+	'http://www.opensource.org/licenses/gpl-2.0.php'        => 'GPL_2',
+	'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt'  => 'GPL_2',
+	'http://www.opensource.org/licenses/gpl-3.0.html'       => 'GPL_3',
+	'http://www.gnu.org/licenses/gpl-3.0.txt'               => 'GPL_3',
+	'http://www.opensource.org/licenses/lgpl-2.1.php'       => 'LGPL_2_1',
+	'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt' => 'LGPL_2_1',
+	'http://www.opensource.org/licenses/lgpl-3.0.html'      => 'LGPL_3_0',
+	'http://www.gnu.org/licenses/lgpl-3.0.txt'              => 'LGPL_3_0',
+	'http://www.opensource.org/licenses/mit-license.php'    => 'MIT',
+	'http://www.mozilla.org/MPL/MPL-1.0.txt'                => 'Mozilla_1_0',
+	'http://www.mozilla.org/MPL/MPL-1.1.txt'                => 'Mozilla_1_1',
+	'http://opensource.org/licenses/mozilla1.1.php'         => 'Mozilla_1_1',
+	'http://www.openssl.org/source/license.html'            => 'OpenSSL',
+	'http://dev.perl.org/licenses/'                         => 'Perl_5',
+	'http://www.opensource.org/licenses/postgresql'         => 'PostgreSQL',
+	'http://trolltech.com/products/qt/licenses/licensing/qpl'  => 'QPL_1_0',
+	'http://h71000.www7.hp.com/doc/83final/BA554_90007/apcs02.html'  => 'SSLeay',
+	'http://www.openoffice.org/licenses/sissl_license.html' => 'Sun',
+	'http://www.zlib.net/zlib_license.html'                 => 'Zlib',
+);
+
 sub _determine_rights_from_rdf
 {
+	my ($self, $f) = @_;
+	unless ($self->{_rdf_copyright_data})
+	{
+		my $model = Module::Install::Admin::RDF::rdf_metadata($self);
+		my $iter  = $model->get_pattern(
+			RDF::Trine::Pattern->new(
+				statement(variable('subject'), $NFO->fileName, variable('filename')),
+				statement(variable('subject'), $DC->license, variable('license')),
+				statement(variable('subject'), $DC->rightsHolder, variable('rights_holder')),
+				statement(variable('rights_holder'), $FOAF->name, variable('name')),
+			),
+		);
+		my %results;
+		while (my $row = $iter->next) {
+			my $l = $row->{license}->uri;
+			$row->{class} = literal("Software::License::$URIS{$l}")
+				if exists $URIS{$l};
+			$results{ $row->{filename}->literal_value } = $row;
+		}
+		$self->{_rdf_copyright_data} = \%results;
+	}
+	
+	if ( my $row = $self->{_rdf_copyright_data}{$f} ) {
+		return (
+			sprintf("Copyright %d %s.", 1900 + (localtime)[5], $row->{name}->literal_value),
+			_SL($row->{class}->literal_value),
+		) if $row->{class} && _SL($row->{class}->literal_value);
+	}
+	
 	return;
 }
 
 		
 		return(
 			$copyright,
-			$guesses[0]->name,
-		) if $copyright;
+			_SL($guesses[0]),
+		) if $copyright && _SL($guesses[0]);
 	}
 	
 	return;

meta/copyrights.pret

+
+f`meta/changes.pret`
+	dc:rightsHolder cpan:TOBYINK;
+	dc:license <http://dev.perl.org/licenses/>;
+.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.