[libmodule-install-rdf-perl] 05/34: Add feature to auto-detect doap:Project URI.

Jonas Smedegaard js at alioth.debian.org
Fri Aug 9 14:36:16 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-rdf-perl.

commit c369e621a0d097de2bfaf822c050522966035530
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date:   Sat Nov 26 17:03:23 2011 +0000

    Add feature to auto-detect doap:Project URI.
    
    --HG--
    branch : Module-Install-RDF
---
 lib/Module/Install/Admin/RDF.pm |   26 +++++++++++++++++++++++---
 lib/Module/Install/RDF.pm       |    2 +-
 meta/changes.ttl                |   12 ++++++++++++
 meta/deps.ttl                   |    2 +-
 4 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/lib/Module/Install/Admin/RDF.pm b/lib/Module/Install/Admin/RDF.pm
index d7f37a3..bae3f60 100644
--- a/lib/Module/Install/Admin/RDF.pm
+++ b/lib/Module/Install/Admin/RDF.pm
@@ -4,11 +4,11 @@ use 5.008;
 use parent qw(Module::Install::Base);
 use strict;
 
+use Object::ID;
 use RDF::Trine qw[];
-use Scalar::Util qw[];
 use URI::file qw[];
 
-our $VERSION = '0.002';
+our $VERSION = '0.003';
 
 my $Model = {};
 
@@ -16,7 +16,7 @@ sub rdf_metadata
 {
 	my ($self) = @_;
 	
-	my $addr = Scalar::Util::refaddr($self->_top);
+	my $addr = object_id($self->_top);
 	return $Model->{$addr} if defined $Model->{$addr};
 	my $model = $Model->{$addr} = RDF::Trine::Model->new;
 	
@@ -37,4 +37,24 @@ sub rdf_metadata
 	return $model;
 }
 
+sub rdf_project_uri
+{
+	my ($self) = @_;
+	my $model = $self->rdf_metadata;
+	
+	my @candidates = $model->subjects(
+		RDF::Trine::iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
+		RDF::Trine::iri('http://usefulinc.com/ns/doap#Project'),
+		);
+	return $candidates[0] if scalar @candidates == 1;
+	
+	my %counts = map {
+		$_ => $model->count_statements($_, undef, undef);
+		} @candidates;	
+	my @best = sort { $counts{$b} <=> $counts{$a} } @candidates;
+	return $best[0] if @best;
+	
+	return undef;
+}
+
 1;
diff --git a/lib/Module/Install/RDF.pm b/lib/Module/Install/RDF.pm
index b4718d2..bbc243a 100644
--- a/lib/Module/Install/RDF.pm
+++ b/lib/Module/Install/RDF.pm
@@ -4,7 +4,7 @@ use 5.008;
 use parent qw(Module::Install::Base);
 use strict;
 
-our $VERSION = '0.002';
+our $VERSION = '0.003';
 our $AUTHOR_ONLY = 1;
 
 sub rdf_metadata
diff --git a/meta/changes.ttl b/meta/changes.ttl
index 91f7164..8f35af0 100644
--- a/meta/changes.ttl
+++ b/meta/changes.ttl
@@ -25,3 +25,15 @@ my:v_0-002
 		dcs:versus my:v_0-001 ;
 		dcs:item   [ a dcs:Packaging ; rdfs:label "Upgrade Module::Package::RDF version."@en ] 
 	] .
+
+my:project :release my:v_0-003 .
+my:v_0-003
+	a               :Version ;
+	dc:issued       "2011-11-26"^^xsd:date ;
+	:revision       "0.003"^^xsd:string ;
+	:file-release   <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/Module-Install-RDF-0.003.tar.gz> ;
+	dcs:changeset [
+		dcs:versus my:v_0-002 ;
+		dcs:item   [ a dcs:Addition ; rdfs:label "rdf_project_uri function which provides heuristics to determine the URI of the primary doap:Project described in the meta directory."@en ] ;
+		dcs:item   [ rdfs:label "Use Object::ID::object_id instead of Scalar::Util::refaddr to uniquely identity Module::Install objects. (Though in a typical installation scenario, this shouldn't matter much.)"@en ]
+	] .
diff --git a/meta/deps.ttl b/meta/deps.ttl
index 4d60581..4f5d06f 100644
--- a/meta/deps.ttl
+++ b/meta/deps.ttl
@@ -2,7 +2,7 @@
 
 <http://purl.org/NET/cpan-uri/dist/Module-Install-RDF/project>
 	:requires
-		"Scalar::Util" ,
+		"Object::ID" ,
 		"Module::Install 1.00" ,
 		"RDF::Trine 0.112" ,
 		"URI::file 4.0" ;

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



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