[SCM] librdf-ns-perl Debian packaging branch, master, updated. debian/20130208-1-22-g47de138
Jakob Voss
voss at gbv.de
Fri Apr 19 13:28:42 UTC 2013
The following commit has been merged in the master branch:
commit 81f3455ed6fc92059fee34dd1438720aef7d9423
Merge: c2efe5867bb898744c86d8896d840999583a5fbd c272b76c5a1c03dec3ebfcd2c0f99b577c74072b
Author: Jakob Voss <voss at gbv.de>
Date: Mon Jan 23 14:56:34 2012 +0100
merge
diff --combined Changes
index b0664fc,bb218f0..9d1f08c
--- a/Changes
+++ b/Changes
@@@ -1,12 -1,12 +1,16 @@@
+20120123 (733 prefixes)
+ added: arecipe,calli,cis,datafaqs,db,dwc,ends,eunis,georss,identity,italy,
+ jita,moby,np,ocd,places,pna,protegedc,swpatho,transit,voidp,vsr,wfdesc,wikipedia
+ changed: daiaserv,media,nfo
+ 20111208 (716 prefixes)
+ added: calli,dwc,eunis,georss,pna,swpatho,voidp
+ introduced blank nodes in RDF::NS::Trine
+ extended command line tool to expand QNames
20111124 (709 prefixes)
added: gnd,grs,htir,infosys,muto,omapi,prf,webbox
changed: commerce
removed: uri
- changed command line tool option syntax
+ modified command line tool option syntax
20111102 (702 prefixes)
new command line tool 'rdfns'
added: vsw
diff --combined dist.ini
index a3a9c08,66055cb..7899b79
--- a/dist.ini
+++ b/dist.ini
@@@ -1,7 -1,7 +1,7 @@@
name = RDF-NS
license = Perl_5
-version = 20111208
-copyright_year = 2011
+version = 20120123
- copyright_year = 2011
++copyright_year = 2012
author = Jakob Voss
copyright_holder = Jakob Voss
diff --combined lib/RDF/NS.pm
index ad9f2e8,18c4c29..89eebad
--- a/lib/RDF/NS.pm
+++ b/lib/RDF/NS.pm
@@@ -103,8 -103,13 +103,13 @@@ sub GET
$_[1];
}
+ sub BLANK {
+ }
+
sub URI {
my $self = shift;
+ return $1 if $_[0] =~ /^<([a-zA-Z][a-zA-Z+.-]*:.+)>$/;
+ return $self->BLANK($_[0]) if $_[0] =~ /^_(:.*)?$/;
return unless shift =~ /^([a-z][a-z0-9]*)?([:_]([^:]+))?$/;
my $ns = $self->{ defined $1 ? $1 : '' };
return unless defined $ns;
@@@ -114,7 -119,8 +119,8 @@@
sub AUTOLOAD {
my $self = shift;
- return unless $AUTOLOAD =~ /^.*::([a-z][a-z0-9]*)(_([^:]+))?$/;
+ return unless $AUTOLOAD =~ /^.*::([a-z][a-z0-9]*)?(_([^:]+)?)?$/;
+ return $self->BLANK( defined $3 ? "_:$3" : '_' ) unless $1;
my $ns = $self->{$1} or return;
my $local = defined $3 ? $3 : shift;
return $self->GET($ns) unless defined $local;
@@@ -125,21 -131,25 +131,25 @@@
=head1 SYNOPSIS
- use RDF::NS '20111208'; # check at compile time
- my $ns = RDF::NS->new('20111208'); # check at runtime
+ use RDF::NS '20120123'; # check at compile time
+ my $ns = RDF::NS->new('20120123'); # check at runtime
$ns->foaf; # http://xmlns.com/foaf/0.1/
$ns->foaf_Person; # http://xmlns.com/foaf/0.1/Person
$ns->foaf('Person'); # http://xmlns.com/foaf/0.1/Person
$ns->URI('foaf:Person'); # http://xmlns.com/foaf/0.1/Person
+ use RDF::NS; # get rid if typing '$' by defining a constant
+ use constant NS => RDF::NS->new('20111208');
+ NS->foaf_Person; # http://xmlns.com/foaf/0.1/Person
+
$ns->SPAQRL('foaf'); # PREFIX foaf: <http://xmlns.com/foaf/0.1/>
$ns->TTL('foaf'); # @prefix foaf: <http://xmlns.com/foaf/0.1/> .
$ns->XMLNS('foaf'); # xmlns:foaf="http://xmlns.com/foaf/0.1/"
# To get RDF::Trine::Node::Resource instead of strings
use RDF::NS::Trine;
- $ns = RDF::NS::Trine->new('20111208');
+ $ns = RDF::NS::Trine->new('20120123');
$ns->foaf_Person; # iri('http://xmlns.com/foaf/0.1/Person')
# load your own mapping
@@@ -190,10 -200,12 +200,12 @@@ include C<warn> to enable warnings
Load namespace mappings from a particular tab-separated file. See NEW for
supported options.
- =method URI ( $short )
+ =method URI ( $short | "<$URI>" )
- Expand a prefixed URI, such as C<foaf:Person>. Alternatively you can expand
- prefixed URIs with method calls, such as C<$ns-E<gt>foaf_Person>.
+ Expand a prefixed URI, such as C<foaf:Person> or C<foaf_Person>. Alternatively
+ you can expand prefixed URIs with method calls, such as C<$ns-E<gt>foaf_Person>.
+ If you pass an URI wrapped in C<E<lt>> and C<E<gt>>, it will not be expanded
+ but returned as given.
=method TTL ( prefix[es] )
diff --combined lib/RDF/NS/Trine.pm
index 46b91a5,ab1f3fc..22751de
--- a/lib/RDF/NS/Trine.pm
+++ b/lib/RDF/NS/Trine.pm
@@@ -4,6 -4,7 +4,7 @@@ package RDF::NS::Trine
#ABSTRACT: Popular RDF namespace prefixes from prefix.cc as RDF::Trine nodes
use RDF::Trine::Node::Resource;
+ use RDF::Trine::Node::Blank;
use parent 'RDF::NS';
@@@ -11,24 -12,32 +12,32 @@@ sub GET
RDF::Trine::Node::Resource->new($_[1]);
}
+ sub BLANK {
+ RDF::Trine::Node::Blank->new($2) if $_[1] =~ /^_(:(.*))?$/;
+ }
+
1;
=head1 SYNOPSIS
use RDF::NS::Trine;
- use constant NS => RDF::NS::Trine->new('20111208');
++ use constant NS => RDF::NS::Trine->new('20120123');
- my $ns = RDF::NS::Trine->new('20120123');
+ NS->foaf_Person; # a RDF::Trine::Node::Resource
+ NS->URI('foaf:Person); # same
+ NS->foaf_Person->uri; # http://xmlns.com/foaf/0.1/Person
- $ns->foaf_Person; # a RDF::Trine::Node::Resource
- $ns->URI('foaf:Person); # same
- $ns->foaf_Person->uri; # http://xmlns.com/foaf/0.1/Person
+ NS->_; # a RDF::Trine::Node::Blank
+ NS->_abc; # a blank node with id 'abc'
+ NS->URI('_:abc'); # same
=head1 DESCRIPTION
In contrast to L<RDF::NS>, which should be consulted for documentation, this
- returns no plain string URIs but instances of L<RDF::Trine::Node::Resource>.
+ returns no plain string URIs but instances of L<RDF::Trine::Node::Resource>
+ or L<RDF::Trine::Node::Blank>.
Before using this module, make sure to install L<RDF::Trine>, which is not
- automatically installed together with L<RDF::NS>!
+ installed automatically together with L<RDF::NS>!
=cut
diff --combined t/trine.t
index f96afad,079ea24..de09de7
--- a/t/trine.t
+++ b/t/trine.t
@@@ -2,7 -2,7 +2,7 @@@ use strict
use warnings;
use Test::More;
--eval { require RDF::Trine::Node::Resource; 1; };
++eval { require RDF::Trine::Node::Resource; };
if ( $@ ) {
diag("RDF::Trine missing - skip tests of RDF::NS::Trine");
ok(1, "skip tests");
@@@ -29,4 -29,14 +29,14 @@@ is( $ns->SPARQL('rdf'), "PREFIX rdf: <$
is( $ns->TTL('rdfs'), "\@prefix rdfs: <$rdfs> .", 'TTL("rdfs")' );
is( $ns->XMLNS('rdfs'), "xmlns:rdfs=\"$rdfs\"", 'XMLNS("rdfs")' );
+ # blank nodes
+ my $b = $ns->URI('_:xy');
+ isa_ok( $b, 'RDF::Trine::Node::Blank' );
+ is( $b->blank_identifier, 'xy', 'blank node' );
+ $b = $ns->_abc;
+ is( $b->blank_identifier, 'abc', 'blank node' );
+ isa_ok( $ns->URI('_:'), 'RDF::Trine::Node::Blank' );
+ isa_ok( $ns->URI('_'), 'RDF::Trine::Node::Blank' );
+ isa_ok( $ns->_, 'RDF::Trine::Node::Blank' );
+
done_testing;
--
librdf-ns-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list