[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:38 UTC 2013


The following commit has been merged in the master branch:
commit 54a60bdc89be2f969ce5ad5042cdfd5765c7a70f
Author: Jakob Voss <jakob at nichtich.de>
Date:   Sat Oct 29 23:29:46 2011 +0200

    better update

diff --git a/lib/RDF/NS.pm b/lib/RDF/NS.pm
index 1f229af..68bfee1 100644
--- a/lib/RDF/NS.pm
+++ b/lib/RDF/NS.pm
@@ -36,7 +36,7 @@ sub LOAD {
                 warn "Skipping invalid $prefix namespace $namespace";
             }
         } elsif ( $warn ) {
-            warn "Skipping unusual prefix $prefix";
+            warn "Skipping unusual prefix '$prefix'";
         }
     }
 
@@ -67,7 +67,8 @@ sub SELECT {
 sub MAP {
     my $self = shift;
     my $code = shift;
-    my @ns = grep { $self->{$_} } map { split /[|, ]+/ } @_;
+    my @ns = @_ ? (grep { $self->{$_} } map { split /[|, ]+/ } @_) 
+        : keys %$self;
     if (wantarray) {
         return map { $code->() } sort @ns;
     } else {
@@ -160,11 +161,11 @@ options include C<warn> to enable warnings.
 =method URI ( $short )
 
 Expand a prefixed URI, such as C<foaf:Person>. Alternatively you can expand
-prefixed URIs with method calls, such as C<<$ns->foaf_Person>>.
+prefixed URIs with method calls, such as C<$ns-E<gt>foaf_Person>.
 
 =method TTL ( prefix[es] )
 
-Returns a Turtle/Notation3 @prefix definition or a list of such definitions
+Returns a Turtle/Notation3 C<@prefix> definition or a list of such definitions
 in list context. Prefixes can be passed as single arguments or separated by
 commas, vertical bars, and spaces.
 
@@ -187,9 +188,9 @@ can be used to assign to a hash. In scalar context, returns the namespace
 of the first prefix that was found. Prefixes can be passed as single arguments
 or separated by commas, vertical bars, and spaces.
 
-=method MAP ( $code, prefix[es] )
+=method MAP ( $code [, prefix[es] ] )
 
-Internally used to select and map particular prefixes, that can be passed as
+Internally used to map particular or all prefixes. Prefixes can be selected as
 single arguments or separated by commas, vertical bars, and spaces. In scalar
 context, C<$_> is set to the first existing prefix (if found) and C<$code> is
 called. In list context, found prefixes are sorted at mapped with C<$code>.
@@ -202,7 +203,7 @@ it just returns C<$uri> unmodified.
 
 =head1 SEE ALSO
 
-There are several CPAN modules to deal with IRI namespaces, for instance
+There are several other CPAN modules to deal with IRI namespaces, for instance
 L<RDF::Trine::Namespace>, L<RDF::Trine::NamespaceMap>, L<RDF::Prefixes>,
 L<RDF::Simple::NS>, L<RDF::RDFa::Parser::Profile::PrefixCC> etc.
 
diff --git a/update.pl b/update.pl
index cc9b994..6faf356 100755
--- a/update.pl
+++ b/update.pl
@@ -4,30 +4,46 @@ use LWP::Simple qw(mirror);
 use RDF::NS;
 use File::Temp;
 
-my $dist = do { local( @ARGV, $/ ) = 'dist.ini'; <> }
-	or die "Failed to read dist.ini";
+# get current version distribution
+my $dist = do { local( @ARGV, $/ ) = 'dist.ini'; <> };
+my $cur_version = $1 if $dist =~ /^\s*version\s*=\s*([^\s]+)/m;
 
-$dist =~ /^\s*version\s*=\s*([^\s]+)/m 
-	or die "dist.ini must include version number";
+# get current prefixes
+$cur_version or die 'current version not found in dist.ini';
+my $cur = RDF::NS->LOAD( "share/$cur_version.txt", warn => 1 );
+die "share/$cur_version.txt is empty" unless %$cur;
 
-# TODO: check version number format and date to give a warning
+# get new current datestamp
+my @t = gmtime;
+my $new_version = sprintf '%4d%02d%02d', $t[5]+1900, $t[4]+1, $t[3];
 
-my $file = "share/$1.txt";
-
-( -f $file ) and die "$file already exists";
-
-open (my $fh, ">", $file) 
-	or die "faile to open $file for writing";
+die "$new_version is not new" if $new_version eq $cur_version;
 
+# download new prefixes
 my $tmp = File::Temp->new->filename;
-
 my $url = "http://prefix.cc/popular/all.file.txt";
-my $prefixcc = mirror($url,$tmp) or die "Failed to load $url";
+mirror($url,$tmp) or die "Failed to load $url";
+my $new = RDF::NS->LOAD( $tmp, warn => 1 );
+
+open (my $txt, ">", "share/$new_version.txt") 
+	or die "failed to open share/$new_version.txt";
+print $txt join( "", $new->MAP( sub { "$_\t".$new->{$_}."\n" } ) );
+
+print "$new_version (" . scalar(keys %$new) . " prefixes)\n"; 
+
+# diff
+my @changed;
+foreach (keys %$new) {
+    if (exists $cur->{$_}) {
+		push (@changed,$_) if $cur->{$_} ne $new->{$_};
+	    delete $cur->{$_};
+    	delete $new->{$_};
+	} 
+}
 
-my $ns = RDF::NS->LOAD( $tmp, warn => 1 );
+print "  added: " . join(",",sort keys %$new) . "\n" if %$new;
+print "  removed: " . join(",",sort keys %$cur) . "\n" if %$cur;
+print "  changed: " . join(",",sort @changed) . "\n" if @changed;
 
-foreach my $prefix (sort keys %$ns) {
-	print $fh "$prefix\t" . $ns->{$prefix} . "\n";
-}
-print "created mapping $file with " . scalar(keys %$ns) . " namespaces.\n";
+# TODO: We could write new dist.ini and Changes and even push to CPAN
 

-- 
librdf-ns-perl Debian packaging



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