| 1 | package App::rdfns; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use RDF::NS; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '20230619'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 8 | bless {}, shift; | |||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=16 SCAR=28.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 8 | my ($self, @ARGV) = @_; | |||||||||||||||||||||||||||
| 16 | 8 | my $format = ''; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 8 | ▶ | return $self->usage if !@ARGV or $ARGV[0] =~ /^(-[?h]|--help)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not @ARGV or $ARGV[0] =~ /^(-[?h]|--help)$/
MC/DC0%0/2
not @ARGV or $ARGV[0] =~ /^(-[?h]|--help)$/
not @ARGV
$ARGV[0] =~ /^(-[?h]|--help)$/
Truth table33%1/3
not(A) or B
A= not @ARGVB= $ARGV[0] =~ /^(-[?h]|--help)$/
| |||||||||||||||||||||||||||||
| 19 | 8 | ▶ | return $self->version if $ARGV[0] =~ /^(-v|--version)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 8 | ▶ | return $self->dates if $ARGV[0] eq '--dates'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 8 | my $ns = RDF::NS->new; | |||||||||||||||||||||||||||
| 23 | 8 | my $sn = $ns->REVERSE; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 8 | foreach my $a (@ARGV) { | |||||||||||||||||||||||||||
| 26 | 11 | ▶ | if ( $a =~ /^([0-9]{8})$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 2 | $ns = RDF::NS->new($a); | |||||||||||||||||||||||||||
| 28 | 2 | $sn = $ns->REVERSE; | |||||||||||||||||||||||||||
| 29 | 2 | next; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 9 | ▶ | if ( $a =~ qr{^https?://} ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 32 | 4 | my $qname = $sn->qname($a); | |||||||||||||||||||||||||||
| 33 | 4 | ▶ | if ($qname) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 2 | $qname =~ s/:$//; | |||||||||||||||||||||||||||
| 35 | 2 | say $qname; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } elsif ( $a =~ /:/ ) { | ||||||||||||||||||||||||||||
| 38 | 0 | print map { $ns->URI($_)."\n" } split(/[|, ]+/, $a); | |||||||||||||||||||||||||||
| 39 | } elsif ( $a =~ s/\.([^.]+)$// ) { | ||||||||||||||||||||||||||||
| 40 | 2 | my $f = $1; | |||||||||||||||||||||||||||
| 41 | 2 | ▶ | if ( $f eq 'prefix' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | print map { "$_\n" if defined $_ } map { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 1 | $sn->{$_} | |||||||||||||||||||||||||||
| 44 | } $ns->FORMAT( $format, $a ); | ||||||||||||||||||||||||||||
| 45 | 1 | next; | |||||||||||||||||||||||||||
| 46 | } elsif ( $f =~ $RDF::NS::FORMATS ) { | ||||||||||||||||||||||||||||
| 47 | 1 | $format = $f; | |||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||
| 49 | 0 | print STDERR "Unknown format: $f\n"; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 8 | ▶ | if ( lc($format) eq 'json' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 1 | say join ",\n", $ns->FORMAT( $format, $a ); | |||||||||||||||||||||||||||
| 54 | } else { | ||||||||||||||||||||||||||||
| 55 | 7 | say $_ for $ns->FORMAT( $format, $a ); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub usage { | ||||||||||||||||||||||||||
|
Subroutine
usage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | print <<'USAGE'; | |||||||||||||||||||||||||||
| 62 | USAGE: rdfns { [YYYYMMDD] ( <prefix[es]>[.format] | prefix:name | URL ) }+ | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | formats: txt, sparql, ttl, n3, xmlns, json, beacon, prefix | ||||||||||||||||||||||||||||
| 65 | options: --help | --version | --dates | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | examples: | ||||||||||||||||||||||||||||
| 68 | rdfns 20111102 foaf,owl.ttl | ||||||||||||||||||||||||||||
| 69 | rdfns foaf.xmlns foaf.n3 | ||||||||||||||||||||||||||||
| 70 | rdfns rdfs:seeAlso | ||||||||||||||||||||||||||||
| 71 | rdfns http://www.w3.org/2003/01/geo/wgs84_pos# | ||||||||||||||||||||||||||||
| 72 | rdfns http://purl.org/dc/elements/1.1/title | ||||||||||||||||||||||||||||
| 73 | rdfns wgs.prefix | ||||||||||||||||||||||||||||
| 74 | USAGE | ||||||||||||||||||||||||||||
| 75 | 0 | 0; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 0 | print $RDF::NS::VERSION . "\n"; | |||||||||||||||||||||||||||
| 80 | 0 | 0; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub dates { | ||||||||||||||||||||||||||
|
Subroutine
dates: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 0 | my $fh = RDF::NS->new->DATA; | |||||||||||||||||||||||||||
| 85 | 0 | my $date = ''; | |||||||||||||||||||||||||||
| 86 | 0 | foreach (<$fh>) { | |||||||||||||||||||||||||||
| 87 | 0 | chomp; | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | next if /^#/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | my @fields = split "\t", $_; | |||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ($fields[2] ne $date) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | say $date=$fields[2]; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 0 | 0; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 1 | 1; | |||||||||||||||||||||||||||
| 98 | __END__ | ||||||||||||||||||||||||||||