[SCM] librdf-ns-perl Debian packaging branch, master, updated. debian/20130208-1-22-g47de138

Jakob Voss jakob at nichtich.de
Fri Apr 19 13:28:39 UTC 2013


The following commit has been merged in the master branch:
commit be178b21662fbc05e1bb939e9e7ae8535c21a49d
Author: Jakob Voss <jakob at nichtich.de>
Date:   Tue Nov 1 22:35:48 2011 +0100

    command line tool 'rdfns'

diff --git a/bin/rdfns b/bin/rdfns
new file mode 100755
index 0000000..414a300
--- /dev/null
+++ b/bin/rdfns
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+#ABSTRACT: quickly get common URI namespaces
+#PODNAME: rdfns
+
+use strict;
+use warnings;
+
+use RDF::NS;
+my $format = 'txt';
+my $version = 'any';
+
+if (!@ARGV or $ARGV[0] =~ /^(-[?h]|--help)$/) {
+     print <DATA>;
+     exit;
+}
+
+while (@ARGV and $ARGV[0] =~ /^-(.+)$/) {
+     if ($1 =~ /^(ttl|n(otation)?3|sparql|xmlns|txt)$/i) {
+         $format = $1;
+     } elsif ($1 =~ /^(\d{8})$/) {
+	     $version = $1;
+     } else {
+         print STDERR "Unknown option ".$ARGV[0]."\n";
+     }
+     shift @ARGV;
+}
+
+print map {"$_\n"} RDF::NS->new($version)->FORMAT( $format, @ARGV );
+
+__DATA__
+USAGE: rdfns [format] [-YYYYMMDD] <prefix[es]>
+
+  formats: -txt, -sparql, -ttl, -n3, -xmlns
+
diff --git a/lib/RDF/NS.pm b/lib/RDF/NS.pm
index 99500ea..97a5399 100644
--- a/lib/RDF/NS.pm
+++ b/lib/RDF/NS.pm
@@ -10,7 +10,7 @@ our $AUTOLOAD;
 
 sub new {
     my $class   = shift;
-    my $version = shift;
+    my $version = shift || 'undef';
 	$version = $RDF::NS::VERSION if $version eq 'any';
     LOAD( $class, File::ShareDir::dist_file('RDF-NS', "$version.txt" ), @_ );
 }
@@ -44,6 +44,16 @@ sub LOAD {
     bless $ns, $class;
 }
 
+sub FORMAT {
+    my $self = shift;
+	my $format = shift;
+    $format = 'TTL' if $format =~ /^n(otation)?3$/i;
+    if ($format =~ /^(ttl|n3|sparql|txt)$/i) {
+	    $format = uc($format);
+	    $self->$format( @_ );
+	}
+}
+
 sub TTL {
     my $self = shift;
     $self->MAP( sub { "\@prefix $_: <".$self->{$_}."> ." } , @_ );
@@ -59,6 +69,12 @@ sub XMLNS {
     $self->MAP( sub { "xmlns:$_=\"".$self->{$_}."\"" } , @_ );
 }
 
+sub TXT {
+    my $self = shift;
+    $self->MAP( sub { "$_\t".$self->{$_} } , @_ );
+}
+
+
 sub SELECT {
     my $self = shift;
     $self->MAP( sub { $_ => $self->{$_} } , @_ );

-- 
librdf-ns-perl Debian packaging



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