[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 758e538dcf7d2cd72770dad80a81461ba388ca40
Author: Jakob Voss <jakob at nichtich.de>
Date: Sun Oct 30 11:38:48 2011 +0100
new 'any' keyword
diff --git a/README.mkdn b/README.mkdn
deleted file mode 100644
index 10ccef7..0000000
--- a/README.mkdn
+++ /dev/null
@@ -1,126 +0,0 @@
-# NAME
-
-RDF::NS - Just use popular RDF namespace prefixes from prefix.cc
-
-# VERSION
-
-version 20111028
-
-# SYNOPSIS
-
- use RDF::NS '20111028';
- my $ns = RDF::NS->new('20111028');
-
- $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
-
- $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
- my $ns = RDF::NS->new( '20111028', as => 'trine' );
- $ns->foaf_Person; # iri('http://xmlns.com/foaf/0.1/Person')
-
- # load your own mapping
- $ns = RDF::NS::LOAD("mapping.txt");
-
- # select particular mappings
- %map = $ns->SELECT('rdf,dc,foaf');
- $uri = $ns->SELECT('foo|bar|doz'); # returns first existing namespace
-
- # instances are just blessed hash references
- $ns->{'foaf'} # http://xmlns.com/foaf/0.1/
- bless { foaf => 'http://xmlns.com/foaf/0.1/' }, 'RDF::NS';
- print (scalar %$ns) . "prefixes\n";
-
-# DESCRIPTION
-
-Hardcoding URI namespaces and prefixes for RDF applications is neither fun nor
-maintainable. In the end we all use more or less the same prefix definitions,
-as collected at [http://prefix.cc](http://prefix.cc). This module includes all these prefixes as
-defined at specific snapshots in time. These snapshots correspond to version
-numbers of this module. By selecting particular versions, you make sure that
-changes at prefix.cc won't affect your scripts.
-
-This module does not require [RDF::Trine](http://search.cpan.org/perldoc?RDF::Trine) which is recommended nevertheless.
-If you prefer RDF::NS to return instances of [RDF::Trine::Node::Resource](http://search.cpan.org/perldoc?RDF::Trine::Node::Resource)
-instead of plain strings, use [RDF::NS::Trine](http://search.cpan.org/perldoc?RDF::NS::Trine).
-
-The code repository of this module contains an
-[update script](https://github.com/nichtich/RDF-NS/blob/master/update.pl)
-to download the current prefix-namespace mappings from [http://prefix.cc](http://prefix.cc).
-
-# METHODS
-
-## new ( $version [, %options ] )
-
-Create a new namespace mapping with a selected version (mandatory).
-See LOAD for supported options.
-
-## LOAD ( $file [, %options ] )
-
-Load namespace mappings from a particular tab-separated file. Supported
-options include `warn` to enable warnings.
-
-## URI ( $short )
-
-Expand a prefixed URI, such as `foaf:Person`. Alternatively you can expand
-prefixed URIs with method calls, such as `<$ns-`foaf_Person>>.
-
-## TTL ( prefix[es] )
-
-Returns a Turtle/Notation3 @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.
-
-## SPARQL ( prefix[es] )
-
-Returns a SPARQL 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.
-
-## XMLNS ( prefix[es] )
-
-Returns an XML namespace declaration or a list of such declarations in list
-context. Prefixes can be passed as single arguments or separated by commas,
-vertical bars, and spaces.
-
-## SELECT ( prefix[es] )
-
-In list context, returns a sorted list of prefix-namespace pairs, which
-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.
-
-## MAP ( $code, prefix[es] )
-
-Internally used to select and map particular prefixes, that can be passed as
-single arguments or separated by commas, vertical bars, and spaces. In scalar
-context, `$_` is set to the first existing prefix (if found) and `$code` is
-called. In list context, found prefixes are sorted at mapped with `$code`.
-
-## GET ( $uri )
-
-This method is used internally to create URIs as return value of the URI
-method and all lowercase shortcut methods, such as `foaf_Person`. By default
-it just returns `$uri` unmodified.
-
-# SEE ALSO
-
-There are several CPAN modules to deal with IRI namespaces, for instance
-[RDF::Trine::Namespace](http://search.cpan.org/perldoc?RDF::Trine::Namespace), L<RDF::Trine::NamespaceMap<>, [RDF::Prefixes](http://search.cpan.org/perldoc?RDF::Prefixes),
-[RDF::Simple::NS](http://search.cpan.org/perldoc?RDF::Simple::NS), [RDF::RDFa::Parser::Profile::PrefixCC](http://search.cpan.org/perldoc?RDF::RDFa::Parser::Profile::PrefixCC) etc.
-
-# AUTHOR
-
-Jakob Voss
-
-# COPYRIGHT AND LICENSE
-
-This software is copyright (c) 2011 by Jakob Voss.
-
-This is free software; you can redistribute it and/or modify it under
-the same terms as the Perl 5 programming language system itself.
\ No newline at end of file
diff --git a/dist.ini b/dist.ini
index b8ac327..dc5a9ca 100644
--- a/dist.ini
+++ b/dist.ini
@@ -12,11 +12,8 @@ copyright_holder = Jakob Voss
[Prereqs]
File::ShareDir = 1.00
-[ReadmeMarkdownFromPod]
-
[PruneFiles]
filename = dist.ini
-filename = README.mkdn
filename = update.pl
filename = lib/auto
diff --git a/lib/RDF/NS.pm b/lib/RDF/NS.pm
index 68bfee1..94f7bb7 100644
--- a/lib/RDF/NS.pm
+++ b/lib/RDF/NS.pm
@@ -11,6 +11,7 @@ our $AUTOLOAD;
sub new {
my $class = shift;
my $version = shift;
+ $version = $RDF::NS::VERSION if $version eq 'any';
LOAD( $class, File::ShareDir::dist_file('RDF-NS', "$version.txt" ), @_ );
}
@@ -102,8 +103,8 @@ sub AUTOLOAD {
=head1 SYNOPSIS
- use RDF::NS;
- my $ns = RDF::NS->new('20111028');
+ use RDF::NS '20111028'; # check at compile time
+ my $ns = RDF::NS->new('20111028'); # check at runtime
$ns->foaf; # http://xmlns.com/foaf/0.1/
$ns->foaf_Person; # http://xmlns.com/foaf/0.1/Person
@@ -150,13 +151,16 @@ to download the current prefix-namespace mappings from L<http://prefix.cc>.
=method new ( $version [, %options ] )
-Create a new namespace mapping with a selected version (mandatory).
-See LOAD for supported options.
+Create a new namespace mapping with a selected version (mandatory). The special
+version string C<"any"> can be used to get the newest mapping - actually this
+is C<$RDF::NS::VERSION>, but you should better select a specific version, as
+mappings can change, violating backwards compatibility. Supported options
+include C<warn> to enable warnings.
=method LOAD ( $file [, %options ] )
-Load namespace mappings from a particular tab-separated file. Supported
-options include C<warn> to enable warnings.
+Load namespace mappings from a particular tab-separated file. See NEW for
+supported options.
=method URI ( $short )
diff --git a/update.pl b/update.pl
index 6faf356..acfd3e0 100755
--- a/update.pl
+++ b/update.pl
@@ -26,24 +26,39 @@ 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";
+ 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";
+my (@log) = "$new_version (" . scalar(keys %$new) . " prefixes)";
# diff
my @changed;
foreach (keys %$new) {
if (exists $cur->{$_}) {
- push (@changed,$_) if $cur->{$_} ne $new->{$_};
- delete $cur->{$_};
- delete $new->{$_};
- }
+ push (@changed,$_) if $cur->{$_} ne $new->{$_};
+ delete $cur->{$_};
+ delete $new->{$_};
+ }
}
-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;
+push @log, " added: " . join(",",sort keys %$new) if %$new;
+push @log, " removed: " . join(",",sort keys %$cur) if %$cur;
+push @log, " changed: " . join(",",sort @changed) if @changed;
-# TODO: We could write new dist.ini and Changes and even push to CPAN
+print join '', map { "$_\n" } @log;
+
+if (@ARGV and @ARGV eq '-m') {
+ foreach my $file (qw(dist.ini lib/RDF/NS.pm lib/RDF/NS/Trine.pm)) {
+ print "$cur_version => $new_version in $file\n";
+ local ($^I, at ARGV)=('.bak',$file);
+ while(<>) {
+ s/$cur_version/$new_version/ig;
+ print;
+ }
+ }
+ # TODO: modify 'Changes'
+ # print join '' map { "$_\n" }, @log;
+ # $ git commit -m "update to $new_version"
+ # $ dzil release
+}
--
librdf-ns-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list