[libmodule-install-doap-perl] 01/34: Ubercool RDF-driven build system.

Jonas Smedegaard js at alioth.debian.org
Thu Aug 8 16:13:44 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libmodule-install-doap-perl.

commit 1cc8d18841ca82fa48e33397e105a523d2e0d3f3
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date:   Sat Oct 1 18:40:42 2011 +0000

    Ubercool RDF-driven build system.
    
    --HG--
    branch : Module-Install-DOAP
    extra : convert_revision : svn%3A3fe8e991-6959-4966-b76d-b07eca2b6e37/Module-Install-DOAP%40953
---
 Makefile.PL                      |    1 +
 Module-Install-DOAP-0.001.tar.gz |  Bin 0 -> 40046 bytes
 TODO                             |    2 +
 lib/Module/Install/Admin/DOAP.pm |  244 ++++++++++++++++++++++++++++++++++++++
 lib/Module/Install/DOAP.pm       |   56 +++++++++
 meta/changes.ttl                 |   18 +++
 meta/deps.ttl                    |   11 ++
 meta/doap.ttl                    |   41 +++++++
 meta/makefile.ttl                |    8 ++
 t/01basic.t                      |    3 +
 10 files changed, 384 insertions(+)

diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..01e5b33
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1 @@
+use inc::Module::Package 'RDF:standard';
diff --git a/Module-Install-DOAP-0.001.tar.gz b/Module-Install-DOAP-0.001.tar.gz
new file mode 100644
index 0000000..13d62f1
Binary files /dev/null and b/Module-Install-DOAP-0.001.tar.gz differ
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..db324e8
--- /dev/null
+++ b/TODO
@@ -0,0 +1,2 @@
+- Document which parts of DOAP, and which extension vocabularies this module uses, and how that's mapped to META.yml, etc.
+- Look at a better way of representing dependencies.
diff --git a/lib/Module/Install/Admin/DOAP.pm b/lib/Module/Install/Admin/DOAP.pm
new file mode 100644
index 0000000..da1e306
--- /dev/null
+++ b/lib/Module/Install/Admin/DOAP.pm
@@ -0,0 +1,244 @@
+package Module::Install::Admin::DOAP;
+
+use 5.008;
+use base qw(Module::Install::Base);
+use strict;
+
+use File::Spec;
+use Module::Install::Admin::RDF;
+use RDF::Trine;
+use URI::file;
+
+our $VERSION = '0.001';
+
+use RDF::Trine::Namespace qw[RDF RDFS OWL XSD];
+my $CPAN = RDF::Trine::Namespace->new('http://purl.org/NET/cpan-uri/terms#');
+my $DC   = RDF::Trine::Namespace->new('http://purl.org/dc/terms/');
+my $DOAP = RDF::Trine::Namespace->new('http://usefulinc.com/ns/doap#');
+my $FOAF = RDF::Trine::Namespace->new('http://xmlns.com/foaf/0.1/');
+my $NFO  = RDF::Trine::Namespace->new('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#');
+my $SKOS = RDF::Trine::Namespace->new('http://www.w3.org/2004/02/skos/core#');
+
+sub doap_metadata
+{
+	my ($self, $uri) = @_;
+	
+	unless (defined $uri)
+	{
+		my @dirs = File::Spec->splitdir(File::Spec->rel2abs(File::Spec->curdir));
+		$uri = sprintf('http://purl.org/NET/cpan-uri/dist/%s/project', $dirs[-1]);
+	}
+	unless (ref $uri)
+	{
+		$uri = RDF::Trine::Node::Resource->new($uri);
+	}
+
+	my $metadata = sub {
+		$self->_top->call(@_);
+		};
+
+	my $model = Module::Install::Admin::RDF::rdf_metadata($self);
+
+	my $name;
+	NAME: foreach ($model->objects_for_predicate_list($uri, $DOAP->name, $FOAF->name, $RDFS->label))
+	{
+		next NAME unless $_->is_literal;
+		$name = $_->literal_value;
+		$metadata->(name => $_->literal_value);
+		last NAME;
+	}
+
+	my $mname;
+	MNAME: foreach ($model->objects_for_predicate_list($uri, $CPAN->module_name))
+	{
+		next MNAME unless $_->is_literal;
+		$mname = $_->literal_value;
+		$metadata->(module_name => $_->literal_value);
+		last MNAME;
+	}
+	if (defined $name and !defined $mname)
+	{
+		$mname = $name;
+		$mname =~ s/-/::/g;
+		$metadata->(module_name => $mname);
+	}
+
+	DESC: foreach ($model->objects_for_predicate_list($uri, $DOAP->shortdesc, $DC->abstract))
+	{
+		next DESC unless $_->is_literal;
+		$metadata->(abstract => $_->literal_value);
+		last DESC;
+	}
+
+	LICENSE: foreach ($model->objects_for_predicate_list($uri, $DOAP->license, $DC->license))
+	{
+		next LICENSE unless $_->is_resource;
+		
+		my $license_code = {
+			'http://www.gnu.org/licenses/agpl-3.0.txt'              => 'open_source',
+			'http://www.apache.org/licenses/LICENSE-1.1'            => 'apache_1_1',
+			'http://www.apache.org/licenses/LICENSE-2.0'            => 'apache',
+			'http://www.apache.org/licenses/LICENSE-2.0.txt'        => 'apache',
+			'http://www.perlfoundation.org/artistic_license_1_0'    => 'artistic',
+			'http://opensource.org/licenses/artistic-license.php'   => 'artistic',
+			'http://www.perlfoundation.org/artistic_license_2_0'    => 'artistic_2',
+			'http://opensource.org/licenses/artistic-license-2.0.php'  => 'artistic_2',
+			'http://www.opensource.org/licenses/bsd-license.php'    => 'bsd',
+			'http://creativecommons.org/publicdomain/zero/1.0/'     => 'unrestricted',
+			'http://www.freebsd.org/copyright/freebsd-license.html' => 'open_source',
+			'http://www.gnu.org/copyleft/fdl.html'                  => 'open_source',
+			'http://www.opensource.org/licenses/gpl-license.php'    => 'gpl',
+			'http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt'  => 'gpl',
+			'http://www.opensource.org/licenses/gpl-2.0.php'        => 'gpl2',
+			'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt'  => 'gpl2',
+			'http://www.opensource.org/licenses/gpl-3.0.html'       => 'gpl3',
+			'http://www.gnu.org/licenses/gpl-3.0.txt'               => 'gpl3',
+			'http://www.opensource.org/licenses/lgpl-license.php'   => 'lgpl',
+			'http://www.opensource.org/licenses/lgpl-2.1.php'       => 'lgpl2',
+			'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt' => 'lgpl2',
+			'http://www.opensource.org/licenses/lgpl-3.0.html'      => 'lgpl3',
+			'http://www.gnu.org/licenses/lgpl-3.0.txt'              => 'lgpl3',
+			'http://www.opensource.org/licenses/mit-license.php'    => 'mit',
+			'http://www.mozilla.org/MPL/MPL-1.0.txt'                => 'mozilla',
+			'http://www.mozilla.org/MPL/MPL-1.1.txt'                => 'mozilla',
+			'http://opensource.org/licenses/mozilla1.1.php'         => 'mozilla',
+			'http://www.openssl.org/source/license.html'            => 'open_source',
+			'http://dev.perl.org/licenses/'                         => 'perl',
+			'http://www.opensource.org/licenses/postgresql'         => 'open_source',
+			'http://trolltech.com/products/qt/licenses/licensing/qpl'  => 'open_source',
+			'http://h71000.www7.hp.com/doc/83final/BA554_90007/apcs02.html'  => 'unrestricted',
+			'http://www.openoffice.org/licenses/sissl_license.html' => 'open_source',
+			'http://www.zlib.net/zlib_license.html'                 => 'open_source',
+			}->{ $_->uri } || undef;
+
+		$metadata->(license => $license_code);
+		last LICENSE;
+	}
+	
+	my %resources;
+	($resources{license}) = 
+		map  { $_->uri }
+		grep { $_->is_resource }
+		$model->objects_for_predicate_list($uri, $DOAP->license, $DC->license);
+	($resources{homepage}) = 
+		map  { $_->uri }
+		grep { $_->is_resource }
+		$model->objects_for_predicate_list($uri, $DOAP->homepage, $FOAF->homepage, $FOAF->page);
+	($resources{bugtracker}) = 
+		map  { $_->uri }
+		grep { $_->is_resource }
+		$model->objects($uri, $DOAP->uri('bug-database'));
+	REPO: foreach my $repo ($model->objects($uri, $DOAP->repository))
+	{
+		next REPO if $repo->is_literal;
+		($resources{repository}) = 
+			map  { $_->uri }
+			grep { $_->is_resource }
+			$model->objects($repo, $DOAP->uri('browse'));
+		last REPO if $resources{repository};
+	}
+	($resources{MailingList}) = 
+		map  { $_->uri }
+		grep { $_->is_resource }
+		$model->objects($uri, $DOAP->uri('mailing-list'));
+	($resources{Wiki}) = 
+		map  { $_->uri }
+		grep { $_->is_resource }
+		$model->objects($uri, $DOAP->uri('wiki'));
+	$metadata->(resources => %resources);
+
+	my %keywords;
+	CATEGORY: foreach my $cat ($model->objects_for_predicate_list($uri, $DOAP->category, $DC->subject))
+	{
+		if ($cat->is_literal)
+		{
+			$keywords{ uc $cat->literal_value } = $cat->literal_value;
+		}
+		else
+		{
+			LABEL: foreach my $label ($model->objects_for_predicate_list($cat, $SKOS->prefLabel, $RDFS->label, $DOAP->name, $FOAF->name))
+			{
+				next LABEL unless $label->is_literal;
+				$keywords{ uc $label->literal_value } = $label->literal_value;
+				next CATEGORY;
+			}
+		}
+	}
+	$metadata->(keywords => sort values %keywords);
+	
+	my %authors;
+	AUTHOR: foreach my $author ($model->objects_for_predicate_list($uri, $DOAP->developer, $DOAP->maintainer, $FOAF->maker, $DC->creator))
+	{
+		my ($name) =
+			map  { $_->literal_value }
+			grep { $_->is_literal }
+			$model->objects_for_predicate_list($author, $FOAF->name, $RDFS->label);
+		my ($mbox) =
+			map  { my $x = $_->uri; $x =~ s/^mailto://i; $x; }
+			grep { $_->is_resource }
+			$model->objects_for_predicate_list($author, $FOAF->mbox);
+		
+		my $str = do
+			{
+				if ($name and $mbox)
+					{ "$name <$mbox>"; }
+				elsif ($name)
+					{ $name; }
+				elsif ($mbox)
+					{ $mbox; }
+				else
+					{ "$author"; }
+			};
+		$authors{uc $str} = $str;
+	}
+	$metadata->(authors => sort values %authors);
+
+	{
+		my @terms = qw(requires build_requires configure_requires recommends test_requires);
+		foreach my $term (@terms)
+		{
+			foreach my $dep ($model->objects($uri, $CPAN->$term))
+			{
+				if ($dep->is_literal)
+				{
+					my ($mod, $ver) = split /\s+/, $dep->literal_value;
+					$ver ||= 0;
+					$metadata->($term => $mod => $ver);
+				}
+				else
+				{
+					warn "Dunno what to do with ${dep}... we'll figure something out eventually.";
+				}
+			}
+		}
+	}
+
+	{
+		my @terms = qw(abstract_from author_from license_from perl_version_from readme_from version_from
+			no_index install_script requires_external_bin);
+		TERM: foreach my $term (@terms)
+		{
+			foreach my $val ($model->objects($uri, $CPAN->$term))
+			{
+				if ($val->is_literal)
+				{
+					$metadata->($term => $val->literal_value);
+					next TERM;
+				}
+				else
+				{
+					foreach my $name ($model->objects($val, $NFO->fileName))
+					{
+						if ($name->is_literal)
+						{
+							$metadata->($term => $name->literal_value);
+							next TERM;
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+1;
diff --git a/lib/Module/Install/DOAP.pm b/lib/Module/Install/DOAP.pm
new file mode 100644
index 0000000..14b9573
--- /dev/null
+++ b/lib/Module/Install/DOAP.pm
@@ -0,0 +1,56 @@
+package Module::Install::DOAP;
+
+use 5.008;
+use base qw(Module::Install::Base);
+use strict;
+
+our $VERSION = '0.001';
+our $AUTHOR_ONLY = 1;
+
+sub doap_metadata
+{
+	my $self = shift;
+	$self->admin->doap_metadata(@_) if $self->is_admin;
+}
+
+1;
+
+__END__
+=head1 NAME
+
+Module::Install::DOAP - generate META.yml data from DOAP
+
+=head1 SYNOPSIS
+
+In Makefile.PL:
+
+  rdf_metadata;
+  doap_metadata;
+  
+=head1 DESCRIPTION
+
+This Module::Install plugin generates your META.yml file from RDF data
+(especially DOAP) in your distribution's 'meta' directory.
+
+=head1 BUGS
+
+Please report any bugs to L<http://rt.cpan.org/>.
+
+=head1 SEE ALSO
+
+L<Module::Install>, L<Module::Install::DOAPChangeSets> .
+
+L<http://www.perlrdf.org/>.
+
+=head1 AUTHOR
+
+Toby Inkster E<lt>tobyink at cpan.orgE<gt>.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2011 by Toby Inkster
+
+This library is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
diff --git a/meta/changes.ttl b/meta/changes.ttl
new file mode 100644
index 0000000..77e24ca
--- /dev/null
+++ b/meta/changes.ttl
@@ -0,0 +1,18 @@
+ at prefix :        <http://usefulinc.com/ns/doap#> .
+ at prefix dcs:     <http://ontologi.es/doap-changeset#> .
+ at prefix dc:      <http://purl.org/dc/terms/> .
+ at prefix foaf:    <http://xmlns.com/foaf/0.1/> .
+ at prefix my:      <http://purl.org/NET/cpan-uri/dist/Module-Install-DOAP/> .
+ at prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+ at prefix toby:    <http://tobyinkster.co.uk/#> .
+ at prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+
+my:project :release my:v_0-001 .
+my:v_0-001
+
+	a               :Version ;
+	dc:issued       "2011-10-01"^^xsd:date ;
+	:revision       "0.001"^^xsd:string ;
+	:file-release   <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/Module-Install-DOAP-0.001.tar.gz> ;
+	rdfs:label      "Initial release" .
+
diff --git a/meta/deps.ttl b/meta/deps.ttl
new file mode 100644
index 0000000..126b952
--- /dev/null
+++ b/meta/deps.ttl
@@ -0,0 +1,11 @@
+ at prefix : <http://purl.org/NET/cpan-uri/terms#> .
+
+<http://purl.org/NET/cpan-uri/dist/Module-Install-DOAP/project>
+	:requires
+		"File::Spec 3.0" ,
+		"Module::Install 1.00" ,
+		"Module::Install::RDF 0.001" ,
+		"RDF::Trine 0.112" ,
+		"URI::file 4.0" ;
+	:test_requires
+		"Test::More 0.61" .
diff --git a/meta/doap.ttl b/meta/doap.ttl
new file mode 100644
index 0000000..3175eab
--- /dev/null
+++ b/meta/doap.ttl
@@ -0,0 +1,41 @@
+ at prefix :        <http://usefulinc.com/ns/doap#> .
+ at prefix dcs:     <http://ontologi.es/doap-changeset#> .
+ at prefix dc:      <http://purl.org/dc/terms/> .
+ at prefix foaf:    <http://xmlns.com/foaf/0.1/> .
+ at prefix my:      <http://purl.org/NET/cpan-uri/dist/Module-Install-DOAP/> .
+ at prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+ at prefix toby:    <http://tobyinkster.co.uk/#> .
+ at prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+
+my:project
+
+	a               :Project ;
+	:name           "Module-Install-DOAP" ;
+	:shortdesc      "generate META.yml data from DOAP"@en ;
+	:programming-language  "Perl" ;
+	:homepage       <https://metacpan.org/release/Module-Install-DOAP> ;
+	:download-page  <https://metacpan.org/release/Module-Install-DOAP> ;
+	:bug-database   <http://rt.cpan.org/Dist/Display.html?Queue=Module-Install-DOAP> ;
+	:repository     [ a :SVNRepository ; :browse <http://goddamn.co.uk/svn-web/perlmods/browse/Module-Install-DOAP/> ] ;
+	:maintainer     toby:i ;
+	:developer      toby:i ;
+	:documenter     toby:i ;
+	:tester         toby:i ;
+	:created        "2011-09-30"^^xsd:date ;
+	:license        <http://dev.perl.org/licenses/> ;
+	:category
+		[ rdfs:label "RDF" ] ,
+		[ rdfs:label "Semantic Web" ] ,
+		[ rdfs:label "CPAN" ] ,
+		[ rdfs:label "DOAP" ] ,
+		[ rdfs:label "Metadata" ] ,
+		[ rdfs:label "Packaging" ] .
+
+toby:i
+
+	a               foaf:Person ;
+	foaf:name       "Toby Inkster" ;
+	foaf:homepage   <http://tobyinkster.co.uk/> ;
+	foaf:page       <https://metacpan.org/author/TOBYINK> ;
+	foaf:mbox       <mailto:tobyink at cpan.org> ;
+	<http://www.w3.org/2002/07/owl#sameAs> <http://purl.org/NET/cpan-uri/person/tobyink> .
diff --git a/meta/makefile.ttl b/meta/makefile.ttl
new file mode 100644
index 0000000..923944b
--- /dev/null
+++ b/meta/makefile.ttl
@@ -0,0 +1,8 @@
+ at prefix : <http://purl.org/NET/cpan-uri/terms#> .
+
+<http://purl.org/NET/cpan-uri/dist/Module-Install-DOAP/project>
+	:perl_version_from _:main ;
+	:version_from _:main ;
+	:readme_from _:main .
+
+_:main <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName> "lib/Module/Install/DOAP.pm" .
diff --git a/t/01basic.t b/t/01basic.t
new file mode 100644
index 0000000..b83bc91
--- /dev/null
+++ b/t/01basic.t
@@ -0,0 +1,3 @@
+use Test::More tests => 2;
+BEGIN { use_ok('Module::Install::RDF') };
+BEGIN { use_ok('Module::Install::Admin::RDF') };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmodule-install-doap-perl.git



More information about the Pkg-perl-cvs-commits mailing list