| 1 | package Dallycot::Model; | ||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:JSMITH'; | |||||||||||||
| 3 | |||||||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 1 | ▶ | use RDF::Trine; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | ▶ | use RDF::Trine::Serializer::TSV; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | has model => ( | ||||||||||||||
| 10 | is => 'ro', | ||||||||||||||
| 11 | isa => 'RDF::Trine::Model', | ||||||||||||||
| 12 | 2 | ▶ | default => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 2 | RDF::Trine::Model -> new | |||||||||||||
| 14 | }, | ||||||||||||||
| 15 | 1 | lazy => 1, | |||||||||||||
| 16 | handles => [qw/ | ||||||||||||||
| 17 | add_statement | ||||||||||||||
| 18 | add_list | ||||||||||||||
| 19 | objects | ||||||||||||||
| 20 | /] | ||||||||||||||
| 21 | ); | ||||||||||||||
| 22 | |||||||||||||||
| 23 | has _prefixes => ( | ||||||||||||||
| 24 | isa => 'RDF::Trine::NamespaceMap', | ||||||||||||||
| 25 | is => 'ro', | ||||||||||||||
| 26 | 2 | ▶ | default => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 27 | 2 | RDF::Trine::NamespaceMap->new({ | |||||||||||||
| 28 | 'loc' => 'http://www.dallycot.net/ns/loc/1.0#', | ||||||||||||||
| 29 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||||||||||||||
| 30 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', | ||||||||||||||
| 31 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', | ||||||||||||||
| 32 | }) | ||||||||||||||
| 33 | }, | ||||||||||||||
| 34 | 1 | handles => {qw/ | |||||||||||||
| 35 | expand_uri uri | ||||||||||||||
| 36 | /} | ||||||||||||||
| 37 | ); | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 0 | ▶ | sub run { | ||||||||||||
|
Subroutine
run: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||
| 40 | 0 | my($self, $uri) = @_; | |||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | my $loc = 'http://www.dallycot.net/ns/loc/1.0#'; | |||||||||||||
| 43 | 0 | my $loc_length = length($loc); | |||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | ▶ | if(!blessed($uri)) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | 0 | $uri = RDF::Trine::Node::Resource->new($uri); | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | my @types = map { | ||||||||||||||
| 50 | 0 | substr($_, $loc_length) | |||||||||||||
| 51 | } grep { | ||||||||||||||
| 52 | 0 | substr($_, 0, $loc_length) eq $loc | |||||||||||||
| 53 | } $self -> _types($uri); | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 0 | ▶ | if(@types > 1) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 56 | 0 | croak $uri->value . " is not a unique linked open code type"; | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | elsif(@types == 1) { | ||||||||||||||
| 59 | 0 | my $method = $self -> can("run_".$types[0]); | |||||||||||||
| 60 | |||||||||||||||
| 61 | 0 | ▶ | if(!$method) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 62 | 0 | ▶ | croak(($uri->value // '(nil)') . " is not a valid linked open code type"); | ||||||||||||
|
Condition0%0/2
$uri->value // "(nil)"
MC/DC0%0/1
$uri->value // "(nil)"
$uri->value
Truth table0%0/2
A
A= $uri->value
| |||||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | 0 | return $self -> $method($uri); | |||||||||||||
| 66 | } | ||||||||||||||
| 67 | else { | ||||||||||||||
| 68 | # it is probably a value - so we build out a Perl object to represent it | ||||||||||||||
| 69 | |||||||||||||||
| 70 | } | ||||||||||||||
| 71 | } | ||||||||||||||
| 72 | |||||||||||||||
| 73 | 0 | ▶ | sub run_Application { | ||||||||||||
|
Subroutine
run_Application: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 74 | 0 | my($self, $uri) = @_; | |||||||||||||
| 75 | |||||||||||||||
| 76 | |||||||||||||||
| 77 | } | ||||||||||||||
| 78 | |||||||||||||||
| 79 | 0 | ▶ | sub run_Sequence { | ||||||||||||
|
Subroutine
run_Sequence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 80 | 0 | my($self, $uri) = @_; | |||||||||||||
| 81 | |||||||||||||||
| 82 | # $uri points to a linked list, but also has a set of assignments that | ||||||||||||||
| 83 | # need to be calculated | ||||||||||||||
| 84 | |||||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | 0 | ▶ | sub run_GuardedSequence { | ||||||||||||
|
Subroutine
run_GuardedSequence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 88 | 0 | my($self, $uri) = @_; | |||||||||||||
| 89 | |||||||||||||||
| 90 | } | ||||||||||||||
| 91 | |||||||||||||||
| 92 | 0 | ▶ | sub _types { | ||||||||||||
|
Subroutine
_types: not called CC=1 SCAR=6.9
| |||||||||||||||
| 93 | 0 | my($self, $uri) = @_; | |||||||||||||
| 94 | |||||||||||||||
| 95 | map { | ||||||||||||||
| 96 | 0 | $_ -> uri_value | |||||||||||||
| 97 | } $self -> model -> objects( | ||||||||||||||
| 98 | $uri, | ||||||||||||||
| 99 | $self -> expand_uri('rdf:type'), | ||||||||||||||
| 100 | undef, | ||||||||||||||
| 101 | type => 'node' | ||||||||||||||
| 102 | ); | ||||||||||||||
| 103 | } | ||||||||||||||
| 104 | |||||||||||||||
| 105 | 2 | ▶ | sub as_turtle { | ||||||||||||
|
Subroutine
as_turtle: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 106 | 2 | my($self) = @_; | |||||||||||||
| 107 | |||||||||||||||
| 108 | 2 | my $serializer = RDF::Trine::Serializer::Turtle -> new( | |||||||||||||
| 109 | namespaces => RDF::Trine::NamespaceMap->new({ | ||||||||||||||
| 110 | 'loc' => 'http://www.dallycot.net/ns/loc/1.0#', | ||||||||||||||
| 111 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||||||||||||||
| 112 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', | ||||||||||||||
| 113 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', | ||||||||||||||
| 114 | }) | ||||||||||||||
| 115 | ); | ||||||||||||||
| 116 | 2 | return $serializer -> serialize_model_to_string($self -> model); | |||||||||||||
| 117 | } | ||||||||||||||
| 118 | |||||||||||||||
| 119 | 0 | ▶ | sub as_ntriples { | ||||||||||||
|
Subroutine
as_ntriples: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 120 | 0 | my($self) = @_; | |||||||||||||
| 121 | |||||||||||||||
| 122 | 0 | my $serializer = RDF::Trine::Serializer::NTriples::Canonical -> new( | |||||||||||||
| 123 | ); | ||||||||||||||
| 124 | 0 | return $serializer -> serialize_model_to_string($self -> model); | |||||||||||||
| 125 | } | ||||||||||||||
| 126 | |||||||||||||||
| 127 | 0 | ▶ | sub as_tsv { | ||||||||||||
|
Subroutine
as_tsv: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 128 | 0 | my($self) = @_; | |||||||||||||
| 129 | |||||||||||||||
| 130 | 0 | my $serializer = RDF::Trine::Serializer::TSV -> new( | |||||||||||||
| 131 | namespaces => RDF::Trine::NamespaceMap->new({ | ||||||||||||||
| 132 | 'loc' => 'http://www.dallycot.net/ns/loc/1.0#', | ||||||||||||||
| 133 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||||||||||||||
| 134 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', | ||||||||||||||
| 135 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', | ||||||||||||||
| 136 | }) | ||||||||||||||
| 137 | ); | ||||||||||||||
| 138 | 0 | return $serializer -> serialize_model_to_string($self -> model); | |||||||||||||
| 139 | } | ||||||||||||||
| 140 | |||||||||||||||
| 141 | 0 | ▶ | sub as_xml { | ||||||||||||
|
Subroutine
as_xml: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 142 | 0 | my($self) = @_; | |||||||||||||
| 143 | |||||||||||||||
| 144 | 0 | my $serializer = RDF::Trine::Serializer::RDFXML -> new( | |||||||||||||
| 145 | namespaces => RDF::Trine::NamespaceMap->new({ | ||||||||||||||
| 146 | 'loc' => 'http://www.dallycot.net/ns/loc/1.0#', | ||||||||||||||
| 147 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||||||||||||||
| 148 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', | ||||||||||||||
| 149 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', | ||||||||||||||
| 150 | }) | ||||||||||||||
| 151 | ); | ||||||||||||||
| 152 | 0 | return $serializer -> serialize_model_to_string($self -> model); | |||||||||||||
| 153 | } | ||||||||||||||
| 154 | |||||||||||||||
| 155 | 0 | ▶ | sub as_dot { | ||||||||||||
|
Subroutine
as_dot: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 156 | 0 | my($self) = @_; | |||||||||||||
| 157 | |||||||||||||||
| 158 | 0 | require RDF::Trine::Exporter::GraphViz; | |||||||||||||
| 159 | |||||||||||||||
| 160 | my $serializer = RDF::Trine::Exporter::GraphViz -> new( | ||||||||||||||
| 161 | namespaces => { | ||||||||||||||
| 162 | 'loc' => 'http://www.dallycot.net/ns/loc/1.0#', | ||||||||||||||
| 163 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||||||||||||||
| 164 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', | ||||||||||||||
| 165 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', | ||||||||||||||
| 166 | }, | ||||||||||||||
| 167 | 0 | ▶ | alias => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||
| 168 | 0 | my($url) = @_; | |||||||||||||
| 169 | 0 | ▶ | return 'nil' if $url eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 170 | 0 | ▶ | return 'a' if $url eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 171 | 0 | ▶ | return 'label' if $url eq 'http://www.w3.org/2000/01/rdf-schema#label'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 172 | 0 | ▶ | return 'head' if $url eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 173 | 0 | ▶ | return 'tail' if $url eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 174 | 0 | ▶ | return 'value' if $url eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#value'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 175 | 0 | undef; | |||||||||||||
| 176 | }, | ||||||||||||||
| 177 | 0 | root => $self->root->value | |||||||||||||
| 178 | ); | ||||||||||||||
| 179 | 0 | return $serializer -> to_string($self -> model); | |||||||||||||
| 180 | } | ||||||||||||||
| 181 | |||||||||||||||
| 182 | |||||||||||||||
| 183 | 1 | 1; | |||||||||||||