[libmodule-install-doapchangesets-perl] 05/47: Push v 0.00_04.
Jonas Smedegaard
js at alioth.debian.org
Fri Aug 9 14:08:35 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-doapchangesets-perl.
commit 0104c68658cea4cda62e8d30f65bc6f184d98a0b
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date: Wed Jan 13 12:15:10 2010 +0000
Push v 0.00_04.
--HG--
branch : Module-Install-DOAPChangeSets
extra : convert_revision : svn%3A3fe8e991-6959-4966-b76d-b07eca2b6e37/Module-Install-DOAPChangeSets%40124
---
Changes | 6 +-
Changes.ttl | 17 +-
Changes.xml | 17 +
MANIFEST | 1 +
META.yml | 4 +-
Makefile.PL | 2 +
Module-Install-DOAPChangeSets-0.00_04.tar.gz | Bin 0 -> 31873 bytes
lib/Module/Install/Admin/DOAPChangeSets.pm | 366 +-------------
lib/Module/Install/DOAPChangeSets.pm | 2 +-
.../DOAPChangeSets.pm => RDF/DOAP/ChangeSets.pm} | 512 ++++++++++++++------
10 files changed, 404 insertions(+), 523 deletions(-)
diff --git a/Changes b/Changes
index a850548..07ca285 100644
--- a/Changes
+++ b/Changes
@@ -2,8 +2,8 @@
## Changes #################################################################
############################################################################
-Module-Install-DOAPChangeSets
-=============================
+<http://search.cpan.org/dist/Module-Install-DOAPChangeSets/#project>
+====================================================================
Created: 2010-01-08
Home page: <http://search.cpan.org/dist/Module-Install-DOAPChangeSets/>
@@ -11,9 +11,9 @@ Bug tracker: <http://rt.cpan.org/Dist/Display.html?Queue=Module-Install-DOAPCha
Maintainer: Toby Inkster <mailto:tobyink at cpan.org>
0.00_03 [2010-01-11] # Omega 3
- - (Addition) Use Text::Wrap to wrap text.
- (Addition) Support Aaron Cope's changefile vocab as a legacy input
format.
+ - (Addition) Use Text::Wrap to wrap text.
- Reverse order of versions in Changelog (newest at top)
0.00_02 [2010-01-08] # Omega 2
diff --git a/Changes.ttl b/Changes.ttl
index d5763de..0aa7a23 100644
--- a/Changes.ttl
+++ b/Changes.ttl
@@ -59,6 +59,20 @@ my:v_0_00_03
[ rdfs:label "Use Text::Wrap to wrap text."@en ; a dcs:Addition ]
] .
+my:v_0_00_04
+
+ a :Version ;
+ dc:issued "2010-01-13"^^xsd:date ;
+ :revision "0.00_04"^^xsd:string ;
+ :file-release <http://backpan.perl.org/authors/id/T/TO/TOBYINK/Module-Install-DOAPChangeSets-0.00_04.tar.gz> ;
+ rdfs:label "Omega 4" ;
+ rdfs:comment "Developer preview."@en ;
+ dcs:changeset [
+ dcs:versus my:v_0_00_03 ;
+ dcs:item
+ [ rdfs:label "Split out RDF::DOAP::ChangeSets as a separate Perl module."@en ]
+ ] .
+
#############################################################
@@ -78,7 +92,8 @@ my:project
:tester toby:i ;
:created "2010-01-08"^^xsd:date ;
:license <http://dev.perl.org/licenses/> ;
- :release my:v_0_00_01 , my:v_0_00_02 , my:v_0_00_03 .
+ :release my:v_0_00_01 , my:v_0_00_02 , my:v_0_00_03 ,
+ my:v_0_00_04 .
#############################################################
diff --git a/Changes.xml b/Changes.xml
index e1985db..6ccf328 100644
--- a/Changes.xml
+++ b/Changes.xml
@@ -66,6 +66,23 @@
<rdfs:comment xml:lang="en">Developer preview.</rdfs:comment>
<rdfs:label>Omega 3</rdfs:label>
</Version>
+ <Version rdf:about="http://search.cpan.org/dist/Module-Install-DOAPChangeSets/#v_0_00_04">
+ <dcs:changeset>
+ <rdf:Description>
+ <dcs:item>
+ <rdf:Description>
+ <rdfs:label xml:lang="en">Split out RDF::DOAP::ChangeSets as a separate Perl module.</rdfs:label>
+ </rdf:Description>
+ </dcs:item>
+ <dcs:versus rdf:resource="http://search.cpan.org/dist/Module-Install-DOAPChangeSets/#v_0_00_03"/>
+ </rdf:Description>
+ </dcs:changeset>
+ <dc:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2010-01-13</dc:issued>
+ <file-release rdf:resource="http://backpan.perl.org/authors/id/T/TO/TOBYINK/Module-Install-DOAPChangeSets-0.00_04.tar.gz"/>
+ <revision rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.00_04</revision>
+ <rdfs:comment xml:lang="en">Developer preview.</rdfs:comment>
+ <rdfs:label>Omega 4</rdfs:label>
+ </Version>
<Project rdf:about="http://search.cpan.org/dist/Module-Install-DOAPChangeSets/#project">
<bug-database rdf:resource="http://rt.cpan.org/Dist/Display.html?Queue=Module-Install-DOAPChangeSets"/>
<created rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2010-01-08</created>
diff --git a/MANIFEST b/MANIFEST
index 230fa07..aa9fab4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -11,6 +11,7 @@ SIGNATURE
lib/Module/Install/DOAPChangeSets/Format.pod
lib/Module/Install/Admin/DOAPChangeSets.pm
lib/Module/Install/DOAPChangeSets.pm
+lib/RDF/DOAP/ChangeSets.pm
t/00sig.t
t/01basic.t
diff --git a/META.yml b/META.yml
index 18e3fb3..2ff15df 100644
--- a/META.yml
+++ b/META.yml
@@ -20,8 +20,10 @@ no_index:
- t
requires:
File::Slurp: 0
+ LWP::Simple: 0
RDF::Query: 2.200
RDF::Trine: 0.112
+ Text::Wrap: 0
URI::file: 0
perl: 5.8.0
resources:
@@ -29,4 +31,4 @@ resources:
homepage: http://search.cpan.org/dist/Module-Install-DOAPChangeSets/
license: http://dev.perl.org/licenses/
repository: http://goddamn.co.uk/viewvc/perlmods/Module-Install-DOAPChangeSets/
-version: 0.00_03
+version: 0.00_04
diff --git a/Makefile.PL b/Makefile.PL
index 9e1b232..77ed815 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -19,7 +19,9 @@ test_requires 'Test::More' => '0.61';
requires 'RDF::Trine' => '0.112';
requires 'RDF::Query' => '2.200';
requires 'File::Slurp' => 0;
+requires 'Text::Wrap' => 0;
requires 'URI::file' => 0;
+requires 'LWP::Simple' => 0;
resources(
'homepage' => "http://search.cpan.org/dist/$dist/",
diff --git a/Module-Install-DOAPChangeSets-0.00_04.tar.gz b/Module-Install-DOAPChangeSets-0.00_04.tar.gz
new file mode 100644
index 0000000..7d8a461
Binary files /dev/null and b/Module-Install-DOAPChangeSets-0.00_04.tar.gz differ
diff --git a/lib/Module/Install/Admin/DOAPChangeSets.pm b/lib/Module/Install/Admin/DOAPChangeSets.pm
index 119030e..2e43791 100644
--- a/lib/Module/Install/Admin/DOAPChangeSets.pm
+++ b/lib/Module/Install/Admin/DOAPChangeSets.pm
@@ -1,265 +1,17 @@
package Module::Install::Admin::DOAPChangeSets;
use strict;
-use RDF::Trine;
-use RDF::Query;
+use RDF::DOAP::ChangeSets;
use File::Slurp qw(slurp);
use URI::file;
use Module::Install::Base;
-use Text::Wrap;
use vars qw{$VERSION @ISA};
BEGIN {
- $VERSION = '0.00_03';
+ $VERSION = '0.00_04';
@ISA = qw{Module::Install::Base};
}
-sub __write_doap_changes__project_data__current
-{
- my $self = shift;
- my $model = shift;
- my $inuri = shift;
-
- my $sparql = "
- PREFIX dc: <http://purl.org/dc/terms/>
- PREFIX dcs: <http://ontologi.es/doap-changeset#>
- PREFIX doap: <http://usefulinc.com/ns/doap#>
- PREFIX foaf: <http://xmlns.com/foaf/0.1/>
- PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- SELECT *
- WHERE
- {
- <$inuri> dc:subject ?project .
- ?project a doap:Project .
- OPTIONAL { <$inuri> dc:title ?title . }
- OPTIONAL { <$inuri> rdfs:label ?title . }
- OPTIONAL { ?project doap:name ?distname . }
- OPTIONAL { ?project rdfs:label ?distname . }
- OPTIONAL { ?project dc:title ?distname . }
- OPTIONAL { ?project doap:created ?created . }
- OPTIONAL { ?project doap:homepage ?homepage . }
- OPTIONAL { ?project doap:bug-database ?bugdatabase . }
- OPTIONAL
- {
- ?project doap:maintainer ?maint .
- ?maint foaf:name ?maintname .
- OPTIONAL { ?maint foaf:mbox ?maintmbox . }
- }
- }
- ";
-
- my $query = RDF::Query->new($sparql);
- my $results = $query->execute($model);
- my $projects = {};
- my $doctitle = '';
- while (my $row = $results->next)
- {
- my $p = $row->{'project'}->as_ntriples;
- $projects->{$p}->{'EXISTS'}++;
- $projects->{$p}->{'distname'} = $row->{'distname'}->literal_value
- if UNIVERSAL::isa($row->{'distname'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'created'} = $row->{'created'}->literal_value
- if UNIVERSAL::isa($row->{'created'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'homepage'}->{ $row->{'homepage'}->uri }++
- if UNIVERSAL::isa($row->{'homepage'}, 'RDF::Trine::Node::Resource');
- $projects->{$p}->{'bugdatabase'}->{ $row->{'bugdatabase'}->uri }++
- if UNIVERSAL::isa($row->{'bugdatabase'}, 'RDF::Trine::Node::Resource');
- $projects->{$p}->{'maint'}->{ $row->{'maint'}->as_ntriples }->{'name'} = $row->{'maintname'}->literal_value
- if UNIVERSAL::isa($row->{'maintname'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'maint'}->{ $row->{'maint'}->as_ntriples }->{'mbox'}->{ $row->{'maintmbox'}->uri }++
- if UNIVERSAL::isa($row->{'maintmbox'}, 'RDF::Trine::Node::Resource');
- $doctitle = $row->{'title'}->literal_value
- if UNIVERSAL::isa($row->{'title'}, 'RDF::Trine::Node::Literal');
- }
-
- foreach my $k (keys %$projects)
- {
- $projects->{$k}->{'distname'} = $self->_top->name
- unless length $projects->{$k}->{'distname'};
- }
-
- return [$projects, $doctitle];
-}
-
-sub __write_doap_changes__project_data__legacy
-{
- my $self = shift;
- my $model = shift;
- my $inuri = shift;
-
- my $sparql = "
- PREFIX dc: <http://purl.org/dc/terms/>
- PREFIX doap: <http://usefulinc.com/ns/doap#>
- PREFIX foaf: <http://xmlns.com/foaf/0.1/>
- PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- SELECT *
- WHERE
- {
- <$inuri> dc:references ?project .
- ?project a doap:Project .
- OPTIONAL { <$inuri> dc:title ?title . }
- OPTIONAL { <$inuri> rdfs:label ?title . }
- OPTIONAL { ?project doap:name ?distname . }
- OPTIONAL { ?project rdfs:label ?distname . }
- OPTIONAL { ?project dc:title ?distname . }
- OPTIONAL { ?project doap:created ?created . }
- OPTIONAL { ?project doap:homepage ?homepage . }
- OPTIONAL { ?project doap:bug-database ?bugdatabase . }
- OPTIONAL
- {
- ?project doap:maintainer ?maint .
- ?maint foaf:name ?maintname .
- OPTIONAL { ?maint foaf:mbox ?maintmbox . }
- }
- }
- ";
-
- my $query = RDF::Query->new($sparql);
- my $results = $query->execute($model);
- my $projects = {};
- my $doctitle = '';
- while (my $row = $results->next)
- {
- my $p = $row->{'project'}->as_ntriples;
- $projects->{$p}->{'EXISTS'}++;
- $projects->{$p}->{'distname'} = $row->{'distname'}->literal_value
- if UNIVERSAL::isa($row->{'distname'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'created'} = $row->{'created'}->literal_value
- if UNIVERSAL::isa($row->{'created'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'homepage'}->{ $row->{'homepage'}->uri }++
- if UNIVERSAL::isa($row->{'homepage'}, 'RDF::Trine::Node::Resource');
- $projects->{$p}->{'bugdatabase'}->{ $row->{'bugdatabase'}->uri }++
- if UNIVERSAL::isa($row->{'bugdatabase'}, 'RDF::Trine::Node::Resource');
- $projects->{$p}->{'maint'}->{ $row->{'maint'}->as_ntriples }->{'name'} = $row->{'maintname'}->literal_value
- if UNIVERSAL::isa($row->{'maintname'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'maint'}->{ $row->{'maint'}->as_ntriples }->{'mbox'}->{ $row->{'maintmbox'}->uri }++
- if UNIVERSAL::isa($row->{'maintmbox'}, 'RDF::Trine::Node::Resource');
- $doctitle = $row->{'title'}->literal_value
- if UNIVERSAL::isa($row->{'title'}, 'RDF::Trine::Node::Literal');
- }
-
- foreach my $k (keys %$projects)
- {
- $projects->{$k}->{'distname'} = $self->_top->name
- unless length $projects->{$k}->{'distname'};
- }
-
- return [$projects, $doctitle];
-}
-
-sub __write_doap_changes__release_data__current
-{
- my $self = shift;
- my $model = shift;
- my $p = shift;
- my $projects = shift;
-
- my $sparql = "
- PREFIX dc: <http://purl.org/dc/terms/>
- PREFIX dcs: <http://ontologi.es/doap-changeset#>
- PREFIX doap: <http://usefulinc.com/ns/doap#>
- PREFIX foaf: <http://xmlns.com/foaf/0.1/>
- PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- SELECT *
- WHERE
- {
- $p doap:release ?version .
- ?version doap:revision ?revision .
- OPTIONAL { ?version dc:issued ?issued . }
- OPTIONAL { ?version rdfs:label ?vname . }
- OPTIONAL
- {
- ?version dcs:changeset [ dcs:item ?item ] .
- OPTIONAL { ?item a ?itemtype . }
- OPTIONAL { ?item rdfs:label ?itemlabel . }
- }
- }
- ";
-
- my $query = RDF::Query->new($sparql);
- my $results = $query->execute($model);
- while (my $row = $results->next)
- {
- my $v = $row->{'version'}->as_ntriples;
- $projects->{$p}->{'v'}->{$v}->{'EXISTS'}++;
-
- $projects->{$p}->{'v'}->{$v}->{'revision'} = $row->{'revision'}->literal_value
- if UNIVERSAL::isa($row->{'revision'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'v'}->{$v}->{'issued'} = $row->{'issued'}->literal_value
- if UNIVERSAL::isa($row->{'issued'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'v'}->{$v}->{'name'} = $row->{'vname'}->literal_value
- if UNIVERSAL::isa($row->{'vname'}, 'RDF::Trine::Node::Literal');
-
- if (UNIVERSAL::isa($row->{'item'}, 'RDF::Trine::Node'))
- {
- my $c = $row->{'item'}->as_ntriples;
- $projects->{$p}->{'v'}->{$v}->{'c'}->{$c}->{'label'} = $row->{'itemlabel'}->literal_value
- if UNIVERSAL::isa($row->{'itemlabel'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'v'}->{$v}->{'c'}->{$c}->{'type'} = $row->{'itemtype'}->uri
- if UNIVERSAL::isa($row->{'itemtype'}, 'RDF::Trine::Node::Resource')
- and $row->{'itemtype'}->uri ne 'http://ontologi.es/doap-changeset#Change';
- }
- }
-}
-
-sub __write_doap_changes__release_data__legacy
-{
- my $self = shift;
- my $model = shift;
- my $p = shift;
- my $projects = shift;
-
- my $sparql = "
- PREFIX dc: <http://purl.org/dc/terms/>
- PREFIX asc: <http://aaronland.info/ns/changefile/>
- PREFIX doap: <http://usefulinc.com/ns/doap#>
- PREFIX foaf: <http://xmlns.com/foaf/0.1/>
- PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- SELECT *
- WHERE
- {
- ?version dc:isVersionOf $p .
- ?version doap:Version [ doap:revision ?revision ] .
- OPTIONAL { ?version doap:Version [ doap:created ?issued ] . }
- OPTIONAL { ?version rdfs:label ?vname . }
- OPTIONAL { ?version asc:changes [ ?itemtype ?itemlabel ] . }
- }
- ";
-
- my $query = RDF::Query->new($sparql);
- my $results = $query->execute($model);
- while (my $row = $results->next)
- {
- my $v = $row->{'version'}->as_ntriples;
- $projects->{$p}->{'v'}->{$v}->{'EXISTS'}++;
-
- $projects->{$p}->{'v'}->{$v}->{'revision'} = $row->{'revision'}->literal_value
- if UNIVERSAL::isa($row->{'revision'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'v'}->{$v}->{'issued'} = $row->{'issued'}->literal_value
- if UNIVERSAL::isa($row->{'issued'}, 'RDF::Trine::Node::Literal');
- $projects->{$p}->{'v'}->{$v}->{'name'} = $row->{'vname'}->literal_value
- if UNIVERSAL::isa($row->{'vname'}, 'RDF::Trine::Node::Literal');
-
- if (UNIVERSAL::isa($row->{'itemlabel'}, 'RDF::Trine::Node'))
- {
- my $c = $row->{'itemlabel'}->as_ntriples;
- $projects->{$p}->{'v'}->{$v}->{'c'}->{$c}->{'label'} = $row->{'itemlabel'}->literal_value
- if UNIVERSAL::isa($row->{'itemlabel'}, 'RDF::Trine::Node::Literal');
-
- if (UNIVERSAL::isa($row->{'itemtype'}, 'RDF::Trine::Node::Resource'))
- {
- my $u = $row->{'itemtype'}->uri;
-
- if ($u =~ m'^http://aaronland.info/ns/changefile/(addition|update|bugfix|removal)$')
- {
- $projects->{$p}->{'v'}->{$v}->{'c'}->{$c}->{'type'} =
- 'http://ontologi.es/doap-changeset#'.(ucfirst $1);
- }
- }
- }
- }
-}
-
sub write_doap_changes
{
my $self = shift;
@@ -268,119 +20,11 @@ sub write_doap_changes
my $fmt = shift || "turtle";
my $type = shift || "auto";
- my $IN = slurp($in);
+ my $data = slurp($in);
my $inuri = URI::file->new_abs($in);
- my $model = RDF::Trine::Model->new( RDF::Trine::Store->temporary_store );
- my $parser = RDF::Trine::Parser->new($fmt);
- $parser->parse_into_model("$inuri", $IN, $model);
-
- if (lc $type eq 'auto')
- {
- my $r = RDF::Query->new(
- "ASK WHERE { ?version <http://ontologi.es/doap-changeset#changeset> ?set .}")
- ->execute($model);
- if ($r->get_boolean)
- {
- $type = 'current';
- }
- else
- {
- $type = 'legacy';
- }
- }
-
- my ($projects, $doctitle);
- if (lc $type eq 'legacy')
- {
- ($projects, $doctitle) = @{ __write_doap_changes__project_data__legacy($self, $model, $inuri) };
- }
- else
- {
- ($projects, $doctitle) = @{ __write_doap_changes__project_data__current($self, $model, $inuri) };
- }
-
- unless (length $doctitle)
- {
- foreach my $project (sort keys %$projects)
- {
- if (length $doctitle == 0
- or length $doctitle > $projects->{$project}->{'distname'})
- {
- $doctitle = $projects->{$project}->{'distname'};
- }
- }
- if (length $doctitle)
- {
- $doctitle = "Changes for $doctitle";
- }
- else
- {
- $doctitle = "Changes";
- }
- }
-
- open OUT, ">$out";
- print OUT "#" x 76 . "\n";
- print OUT "## $doctitle " . ("#" x (72 - length $doctitle)) . "\n";
- print OUT "#" x 76 . "\n\n";
- foreach my $project (sort keys %$projects)
- {
- print OUT $projects->{$project}->{'distname'} . "\n";
- print OUT ('=' x length $projects->{$project}->{'distname'}) . "\n\n";
-
- print OUT sprintf("Created: %s\n", $projects->{$project}->{'created'})
- if $projects->{$project}->{'created'};
- foreach my $u (sort keys %{ $projects->{$project}->{'homepage'} })
- {
- print OUT sprintf("Home page: <%s>\n", $u);
- }
- foreach my $u (sort keys %{ $projects->{$project}->{'bugdatabase'} })
- {
- print OUT sprintf("Bug tracker: <%s>\n", $u);
- }
- foreach my $m (sort keys %{ $projects->{$project}->{'maint'} })
- {
- my @mboxes = sort keys %{$projects->{$project}->{'maint'}->{$m}->{'mbox'}};
- my $mbox = shift @mboxes;
-
- if (defined $mbox) { print OUT sprintf("Maintainer: %s <%s>\n", $projects->{$project}->{'maint'}->{$m}->{'name'}, $mbox); }
- else { print OUT sprintf("Maintainer: %s\n", $projects->{$project}->{'maint'}->{$m}->{'name'}, $mbox); }
- }
- print OUT "\n";
-
- if (lc $type eq 'legacy')
- {
- __write_doap_changes__release_data__legacy($self, $model, $project, $projects);
- }
- else
- {
- __write_doap_changes__release_data__current($self, $model, $project, $projects);
- }
-
- foreach my $version (sort { $b->{'revision'} cmp $a->{'revision'} } values %{$projects->{$project}->{'v'}})
- {
- print OUT $version->{'revision'};
- print OUT sprintf(' [%s]', $version->{'issued'})
- if $version->{'issued'};
- print OUT sprintf(' # %s', $version->{'name'})
- if $version->{'name'};
- print OUT "\n";
- foreach my $change (values %{$version->{'c'}})
- {
- my $sigil = '';
- if (defined $change->{'type'}
- and $change->{'type'} =~ m!doap.changeset.(.+)$!)
- {
- $sigil = '('.$1.') ';
- }
- print OUT wrap(' - ', ' ', sprintf("%s%s", $sigil, $change->{'label'})) . "\n";
- }
- print OUT "\n";
- }
-
- }
- close OUT;
+ my $changeset = RDF::DOAP::ChangeSets->new($inuri, undef, $type, $fmt);
+ $changeset->to_file($out);
}
sub write_doap_changes_xml
diff --git a/lib/Module/Install/DOAPChangeSets.pm b/lib/Module/Install/DOAPChangeSets.pm
index 9821d36..b61c6ac 100644
--- a/lib/Module/Install/DOAPChangeSets.pm
+++ b/lib/Module/Install/DOAPChangeSets.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA};
BEGIN {
- $VERSION = '0.00_03';
+ $VERSION = '0.00_04';
@ISA = 'Module::Install::Base';
}
diff --git a/lib/Module/Install/Admin/DOAPChangeSets.pm b/lib/RDF/DOAP/ChangeSets.pm
similarity index 59%
copy from lib/Module/Install/Admin/DOAPChangeSets.pm
copy to lib/RDF/DOAP/ChangeSets.pm
index 119030e..3298d4d 100644
--- a/lib/Module/Install/Admin/DOAPChangeSets.pm
+++ b/lib/RDF/DOAP/ChangeSets.pm
@@ -1,24 +1,320 @@
-package Module::Install::Admin::DOAPChangeSets;
+#!/usr/bin/perl
+
+=head1 NAME
+
+RDF::DOAP::ChangesSets - Create pretty ChangeLogs from RDF
+
+=head1 SYNOPSIS
+
+ use RDF::DOAP::ChangesSets;
+ use URI::file;
+
+ my $file = 'path/to/changelog.rdf';
+ my $file_uri = URI::file->new_abs($file);
+
+ my $dcs = RDF::DOAP::ChangeSets->new(
+ $file_uri, undef, undef, 'RDFXML');
+ print $dcs->to_string;
+
+=cut
+
+package RDF::DOAP::ChangeSets;
use strict;
+use File::Slurp qw(slurp);
+use LWP::Simple;
use RDF::Trine;
use RDF::Query;
-use File::Slurp qw(slurp);
-use URI::file;
-use Module::Install::Base;
use Text::Wrap;
-use vars qw{$VERSION @ISA};
+=head1 VERSION
+
+0.00_04
+
+Note: this is a developer preview release!
+
+=cut
+
+use vars qw{$VERSION};
BEGIN {
- $VERSION = '0.00_03';
- @ISA = qw{Module::Install::Base};
+ $VERSION = '0.00_04';
}
-sub __write_doap_changes__project_data__current
+=head1 DESCRIPTION
+
+This module takes software changelogs written in the RDF DOAP
+Change Sets vocabulary and produces human-readable changelogs.
+
+=over
+
+=item C<< RDF::DOAP::ChangeSets->new($uri, $data, $type, $fmt) >>
+
+Creates and initialises an object.
+
+$uri is a URL for the input data. The URL is used to query the
+RDF data for the heading of the output changelog. It may be passed
+as either a string, or a L<URI> object.
+
+$data is the RDF data to use as input. It may be passed as a
+string, or as an L<RDF::Trine::Model> object. If undefined,
+this module will attempt to read data from the URL using
+L<LWP::Simple>.
+
+$type gives the constructor a hint as to the RDF vocabulary you
+are using. For DOAP Change Sets, use 'current'; for Aaron Cope's
+Changefile vocab, use 'legacy'; to autodetect, use 'auto'. By
+default, performs autodetection. This module may crash and burn
+if you try to mix both vocabs!!
+
+$fmt provides a hint as to what RDF format you're using. By
+default, Turtle is assumed. Valid values are whatever
+RDF::Trine::Parser->new accepts.
+
+=cut
+
+sub new
{
- my $self = shift;
- my $model = shift;
+ my $class = shift;
my $inuri = shift;
+ my $data = shift;
+ my $type = shift || 'auto';
+
+ my $model;
+ if (ref $data and $data->isa('RDF::Trine::Model'))
+ {
+ $model = $data;
+ }
+ else
+ {
+ $model = RDF::Trine::Model->new( RDF::Trine::Store->temporary_store );
+
+ unless (defined $data)
+ {
+ if (ref $inuri and $inuri->isa('URI::file'))
+ {
+ $data = slurp( $inuri->file );
+ }
+ elsif ($inuri =~ /^(http|file|https|ftp):/i)
+ {
+ $data = get($inuri);
+ }
+ }
+
+ my $fmt = shift || 'turtle';
+ my $parser = RDF::Trine::Parser->new($fmt);
+ $parser->parse_into_model("$inuri", $data, $model);
+ }
+
+ if (lc $type eq 'auto')
+ {
+ my $r = RDF::Query->new(
+ "ASK WHERE { ?version <http://ontologi.es/doap-changeset#changeset> ?set .}")
+ ->execute($model);
+ if ($r->get_boolean)
+ {
+ $type = 'current';
+ }
+ else
+ {
+ $type = 'legacy';
+ }
+ }
+
+ my $self = { 'model' => $model , 'type' => $type , 'uri' => $inuri } ;
+
+ bless $self, $class;
+}
+
+=item C<< $changeset->is_legacy >>
+
+Boolean, indicating if a legacy vocab is being used.
+
+=cut
+
+sub is_legacy
+{
+ my $self = shift;
+ return (lc $self->{'type'} eq 'legacy');
+}
+
+=item C<< $changeset->is_current >>
+
+Boolean, indicating if the current vocab is being used.
+
+=cut
+
+sub is_current
+{
+ my $self = shift;
+ return !$self->is_legacy(@_);
+}
+
+=item C<< $changeset->model >>
+
+RDF::Trine::Model object representing the changelog data.
+
+=cut
+
+sub model
+{
+ my $self = shift;
+ return $self->{'model'};
+}
+
+=item C<< $changeset->uri >>
+
+String representing the changelog URI.
+
+=cut
+
+sub uri
+{
+ my $self = shift;
+ return $self->{'uri'} . '';
+}
+
+=item C<< $changeset->to_string >>
+
+Creates a human-readable representation of the changelog.
+
+=cut
+
+sub to_string
+{
+ my $self = shift;
+ my $rv = '';
+
+ # Get project data for all projects described in the model.
+ $self->_project_data;
+
+ # Heading
+ $rv.= "#" x 76 . "\n";
+ $rv.= "## " . $self->{'doctitle'} . " " . ("#" x (72 - length $self->{'doctitle'})) . "\n";
+ $rv.= "#" x 76 . "\n\n";
+
+ # Create a shortcut to the data.
+ my $projects = $self->{'projects'};
+
+ # foreach project
+ foreach my $project (sort keys %$projects)
+ {
+ # Subheading
+ $rv.= $projects->{$project}->{'distname'} . "\n";
+ $rv.= ('=' x length $projects->{$project}->{'distname'}) . "\n\n";
+
+ # Various interesting data about the project.
+ $rv.= sprintf("Created: %s\n", $projects->{$project}->{'created'})
+ if $projects->{$project}->{'created'};
+ foreach my $u (sort keys %{ $projects->{$project}->{'homepage'} })
+ {
+ $rv.= sprintf("Home page: <%s>\n", $u);
+ }
+ foreach my $u (sort keys %{ $projects->{$project}->{'bugdatabase'} })
+ {
+ $rv.= sprintf("Bug tracker: <%s>\n", $u);
+ }
+ foreach my $m (sort keys %{ $projects->{$project}->{'maint'} })
+ {
+ my @mboxes = sort keys %{$projects->{$project}->{'maint'}->{$m}->{'mbox'}};
+ my $mbox = shift @mboxes;
+
+ if (defined $mbox) { $rv.= sprintf("Maintainer: %s <%s>\n", $projects->{$project}->{'maint'}->{$m}->{'name'}, $mbox); }
+ else { $rv.= sprintf("Maintainer: %s\n", $projects->{$project}->{'maint'}->{$m}->{'name'}, $mbox); }
+ }
+ $rv.= "\n";
+
+ # Read in data about this project's releases.
+ $self->_release_data($project);
+
+ # foreach version
+ foreach my $version (sort { $b->{'revision'} cmp $a->{'revision'} } values %{$projects->{$project}->{'v'}})
+ {
+ # Version number, release data and version name.
+ $rv.= $version->{'revision'};
+ $rv.= sprintf(' [%s]', $version->{'issued'})
+ if $version->{'issued'};
+ $rv.= sprintf(' # %s', $version->{'name'})
+ if $version->{'name'};
+ $rv.= "\n";
+
+ # foreach change
+ foreach my $change (values %{$version->{'c'}})
+ {
+ my $sigil = '';
+ if (defined $change->{'type'}
+ and $change->{'type'} =~ m!doap.changeset.(.+)$!)
+ {
+ $sigil = '('.$1.') ';
+ }
+ # Bullet point
+ $rv.= wrap(' - ', ' ', sprintf("%s%s", $sigil, $change->{'label'})) . "\n";
+ }
+ $rv.= "\n";
+ }
+
+ }
+
+ return $rv;
+}
+
+=item C<< $changeset->to_file($filename) >>
+
+Same as C<to_string>, but outputs to a file.
+
+=cut
+
+sub to_file
+{
+ my $self = shift;
+ my $file = shift;
+
+ open OUT, ">$file";
+ print OUT $self->to_string;
+ close OUT;
+}
+
+sub _project_data
+{
+ my $self = shift;
+ my $rv;
+
+ if ($self->is_legacy)
+ {
+ $rv = $self->_project_data__legacy(@_);
+ }
+ else
+ {
+ $rv = $self->_project_data__current(@_);
+ }
+
+ unless (length $self->{'doctitle'})
+ {
+ foreach my $project (sort keys %{$self->{'projects'}})
+ {
+ if (length $self->{'doctitle'} == 0
+ or length $self->{'doctitle'} > $self->{'projects'}->{$project}->{'distname'})
+ {
+ $self->{'doctitle'} = $self->{'projects'}->{$project}->{'distname'};
+ }
+ }
+ if (length $self->{'doctitle'})
+ {
+ $self->{'doctitle'} = "Changes for " . $self->{'doctitle'};
+ }
+ else
+ {
+ $self->{'doctitle'} = "Changes";
+ }
+ }
+
+ return $rv;
+}
+
+sub _project_data__current
+{
+ my $self = shift;
+ my $model = $self->model;
+ my $inuri = $self->uri;
my $sparql = "
PREFIX dc: <http://purl.org/dc/terms/>
@@ -29,7 +325,6 @@ sub __write_doap_changes__project_data__current
SELECT *
WHERE
{
- <$inuri> dc:subject ?project .
?project a doap:Project .
OPTIONAL { <$inuri> dc:title ?title . }
OPTIONAL { <$inuri> rdfs:label ?title . }
@@ -74,18 +369,18 @@ sub __write_doap_changes__project_data__current
foreach my $k (keys %$projects)
{
- $projects->{$k}->{'distname'} = $self->_top->name
- unless length $projects->{$k}->{'distname'};
+ $projects->{$k}->{'distname'} = $k;
}
- return [$projects, $doctitle];
+ $self->{'projects'} = $projects;
+ $self->{'doctitle'} = $doctitle;
}
-sub __write_doap_changes__project_data__legacy
+sub _project_data__legacy
{
my $self = shift;
- my $model = shift;
- my $inuri = shift;
+ my $model = $self->model;
+ my $inuri = $self->uri;
my $sparql = "
PREFIX dc: <http://purl.org/dc/terms/>
@@ -95,7 +390,6 @@ sub __write_doap_changes__project_data__legacy
SELECT *
WHERE
{
- <$inuri> dc:references ?project .
?project a doap:Project .
OPTIONAL { <$inuri> dc:title ?title . }
OPTIONAL { <$inuri> rdfs:label ?title . }
@@ -140,19 +434,33 @@ sub __write_doap_changes__project_data__legacy
foreach my $k (keys %$projects)
{
- $projects->{$k}->{'distname'} = $self->_top->name
- unless length $projects->{$k}->{'distname'};
+ $projects->{$k}->{'distname'} = $k;
}
- return [$projects, $doctitle];
+ $self->{'projects'} = $projects;
+ $self->{'doctitle'} = $doctitle;
}
-sub __write_doap_changes__release_data__current
+sub _release_data
+{
+ my $self = shift;
+
+ if ($self->is_legacy)
+ {
+ return $self->_release_data__legacy(@_);
+ }
+ else
+ {
+ return $self->_release_data__current(@_);
+ }
+}
+
+sub _release_data__current
{
my $self = shift;
- my $model = shift;
+ my $model = $self->model;
my $p = shift;
- my $projects = shift;
+ my $projects = $self->{'projects'};
my $sparql = "
PREFIX dc: <http://purl.org/dc/terms/>
@@ -202,12 +510,12 @@ sub __write_doap_changes__release_data__current
}
}
-sub __write_doap_changes__release_data__legacy
+sub _release_data__legacy
{
my $self = shift;
- my $model = shift;
+ my $model = $self->model;
my $p = shift;
- my $projects = shift;
+ my $projects = $self->{'projects'};
my $sparql = "
PREFIX dc: <http://purl.org/dc/terms/>
@@ -260,138 +568,30 @@ sub __write_doap_changes__release_data__legacy
}
}
-sub write_doap_changes
-{
- my $self = shift;
- my $in = shift || "Changes.ttl";
- my $out = shift || "Changes";
- my $fmt = shift || "turtle";
- my $type = shift || "auto";
+1;
- my $IN = slurp($in);
- my $inuri = URI::file->new_abs($in);
+__END__
- my $model = RDF::Trine::Model->new( RDF::Trine::Store->temporary_store );
- my $parser = RDF::Trine::Parser->new($fmt);
- $parser->parse_into_model("$inuri", $IN, $model);
-
- if (lc $type eq 'auto')
- {
- my $r = RDF::Query->new(
- "ASK WHERE { ?version <http://ontologi.es/doap-changeset#changeset> ?set .}")
- ->execute($model);
- if ($r->get_boolean)
- {
- $type = 'current';
- }
- else
- {
- $type = 'legacy';
- }
- }
-
- my ($projects, $doctitle);
- if (lc $type eq 'legacy')
- {
- ($projects, $doctitle) = @{ __write_doap_changes__project_data__legacy($self, $model, $inuri) };
- }
- else
- {
- ($projects, $doctitle) = @{ __write_doap_changes__project_data__current($self, $model, $inuri) };
- }
-
- unless (length $doctitle)
- {
- foreach my $project (sort keys %$projects)
- {
- if (length $doctitle == 0
- or length $doctitle > $projects->{$project}->{'distname'})
- {
- $doctitle = $projects->{$project}->{'distname'};
- }
- }
- if (length $doctitle)
- {
- $doctitle = "Changes for $doctitle";
- }
- else
- {
- $doctitle = "Changes";
- }
- }
+=back
- open OUT, ">$out";
- print OUT "#" x 76 . "\n";
- print OUT "## $doctitle " . ("#" x (72 - length $doctitle)) . "\n";
- print OUT "#" x 76 . "\n\n";
- foreach my $project (sort keys %$projects)
- {
- print OUT $projects->{$project}->{'distname'} . "\n";
- print OUT ('=' x length $projects->{$project}->{'distname'}) . "\n\n";
-
- print OUT sprintf("Created: %s\n", $projects->{$project}->{'created'})
- if $projects->{$project}->{'created'};
- foreach my $u (sort keys %{ $projects->{$project}->{'homepage'} })
- {
- print OUT sprintf("Home page: <%s>\n", $u);
- }
- foreach my $u (sort keys %{ $projects->{$project}->{'bugdatabase'} })
- {
- print OUT sprintf("Bug tracker: <%s>\n", $u);
- }
- foreach my $m (sort keys %{ $projects->{$project}->{'maint'} })
- {
- my @mboxes = sort keys %{$projects->{$project}->{'maint'}->{$m}->{'mbox'}};
- my $mbox = shift @mboxes;
-
- if (defined $mbox) { print OUT sprintf("Maintainer: %s <%s>\n", $projects->{$project}->{'maint'}->{$m}->{'name'}, $mbox); }
- else { print OUT sprintf("Maintainer: %s\n", $projects->{$project}->{'maint'}->{$m}->{'name'}, $mbox); }
- }
- print OUT "\n";
-
- if (lc $type eq 'legacy')
- {
- __write_doap_changes__release_data__legacy($self, $model, $project, $projects);
- }
- else
- {
- __write_doap_changes__release_data__current($self, $model, $project, $projects);
- }
+=head1 BUGS
- foreach my $version (sort { $b->{'revision'} cmp $a->{'revision'} } values %{$projects->{$project}->{'v'}})
- {
- print OUT $version->{'revision'};
- print OUT sprintf(' [%s]', $version->{'issued'})
- if $version->{'issued'};
- print OUT sprintf(' # %s', $version->{'name'})
- if $version->{'name'};
- print OUT "\n";
- foreach my $change (values %{$version->{'c'}})
- {
- my $sigil = '';
- if (defined $change->{'type'}
- and $change->{'type'} =~ m!doap.changeset.(.+)$!)
- {
- $sigil = '('.$1.') ';
- }
- print OUT wrap(' - ', ' ', sprintf("%s%s", $sigil, $change->{'label'})) . "\n";
- }
- print OUT "\n";
- }
-
- }
- close OUT;
-}
+Please report any bugs to L<http://rt.cpan.org/>.
-sub write_doap_changes_xml
-{
- my $self = shift;
- my $in = shift || "Changes.ttl";
- my $out = shift || "Changes.xml";
- my $fmt = shift || "turtle";
-
- my $r = system("rapper -q -i $fmt -o rdfxml-abbrev $in >$out");
- warn "Error running 'rapper'\n" if $r;
-}
+=head1 SEE ALSO
-1;
+L<RDF::Trine>, L<Module::Install::DOAPChangeSets>.
+
+L<http://www.perlrdf.org/>.
+
+
+=head1 AUTHOR
+
+Toby Inkster E<lt>tobyink at cpan.orgE<gt>.
+
+=head1 COPYRIGHT
+
+Copyright 2010 Toby Inkster
+
+This library is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmodule-install-doapchangesets-perl.git
More information about the Pkg-perl-cvs-commits
mailing list