line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::rdfns; |
2
|
1
|
|
|
1
|
|
70459
|
use v5.10; |
|
1
|
|
|
|
|
17
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
454
|
use RDF::NS; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
776
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '20230619'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
8
|
|
|
8
|
0
|
7985
|
bless {}, shift; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub run { |
15
|
8
|
|
|
8
|
0
|
32
|
my ($self, @ARGV) = @_; |
16
|
8
|
|
|
|
|
19
|
my $format = ''; |
17
|
|
|
|
|
|
|
|
18
|
8
|
50
|
33
|
|
|
82
|
return $self->usage if !@ARGV or $ARGV[0] =~ /^(-[?h]|--help)$/; |
19
|
8
|
50
|
|
|
|
35
|
return $self->version if $ARGV[0] =~ /^(-v|--version)$/; |
20
|
8
|
50
|
|
|
|
35
|
return $self->dates if $ARGV[0] eq '--dates'; |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
55
|
my $ns = RDF::NS->new; |
23
|
8
|
|
|
|
|
53
|
my $sn = $ns->REVERSE; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
|
|
|
53
|
foreach my $a (@ARGV) { |
26
|
11
|
100
|
|
|
|
69
|
if ( $a =~ /^([0-9]{8})$/ ) { |
27
|
2
|
|
|
|
|
14
|
$ns = RDF::NS->new($a); |
28
|
2
|
|
|
|
|
16
|
$sn = $ns->REVERSE; |
29
|
2
|
|
|
|
|
13
|
next; |
30
|
|
|
|
|
|
|
} |
31
|
9
|
100
|
|
|
|
220
|
if ( $a =~ qr{^https?://} ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
4
|
|
|
|
|
30
|
my $qname = $sn->qname($a); |
33
|
4
|
100
|
|
|
|
18
|
if ($qname) { |
34
|
2
|
|
|
|
|
11
|
$qname =~ s/:$//; |
35
|
2
|
|
|
|
|
17
|
say $qname; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} elsif ( $a =~ /:/ ) { |
38
|
0
|
|
|
|
|
0
|
print map { $ns->URI($_)."\n" } split(/[|, ]+/, $a); |
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
} elsif ( $a =~ s/\.([^.]+)$// ) { |
40
|
2
|
|
|
|
|
16
|
my $f = $1; |
41
|
2
|
100
|
|
|
|
27
|
if ( $f eq 'prefix' ) { |
|
|
50
|
|
|
|
|
|
42
|
1
|
50
|
|
|
|
13
|
print map { "$_\n" if defined $_ } map { |
43
|
1
|
|
|
|
|
8
|
$sn->{$_} |
|
1
|
|
|
|
|
4
|
|
44
|
|
|
|
|
|
|
} $ns->FORMAT( $format, $a ); |
45
|
1
|
|
|
|
|
489
|
next; |
46
|
|
|
|
|
|
|
} elsif ( $f =~ $RDF::NS::FORMATS ) { |
47
|
1
|
|
|
|
|
4
|
$format = $f; |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
0
|
print STDERR "Unknown format: $f\n"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
8
|
100
|
|
|
|
59
|
if ( lc($format) eq 'json' ) { |
53
|
1
|
|
|
|
|
7
|
say join ",\n", $ns->FORMAT( $format, $a ); |
54
|
|
|
|
|
|
|
} else { |
55
|
7
|
|
|
|
|
46
|
say $_ for $ns->FORMAT( $format, $a ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub usage { |
61
|
0
|
|
|
0
|
0
|
|
print <<'USAGE'; |
62
|
|
|
|
|
|
|
USAGE: rdfns { [YYYYMMDD] ( [.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
|
|
|
|
|
|
|
sub version { |
79
|
0
|
|
|
0
|
0
|
|
print $RDF::NS::VERSION . "\n"; |
80
|
0
|
|
|
|
|
|
0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub dates { |
84
|
0
|
|
|
0
|
0
|
|
my $fh = RDF::NS->new->DATA; |
85
|
0
|
|
|
|
|
|
my $date = ''; |
86
|
0
|
|
|
|
|
|
foreach (<$fh>) { |
87
|
0
|
|
|
|
|
|
chomp; |
88
|
0
|
0
|
|
|
|
|
next if /^#/; |
89
|
0
|
|
|
|
|
|
my @fields = split "\t", $_; |
90
|
0
|
0
|
|
|
|
|
if ($fields[2] ne $date) { |
91
|
0
|
|
|
|
|
|
say $date=$fields[2]; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
|
0; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
__END__ |