| 1 | package RDF::vCard::Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | no warnings qw(uninitialized); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use MIME::Base64 qw[]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use RDF::vCard::Entity; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use RDF::vCard::Line; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | use RDF::TrineX::Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | -shortcuts, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | iri => { -as => 'rdf_resource' }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Scalar::Util qw[blessed]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # kinda constants | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 24 | ▶ | sub V { return 'http://www.w3.org/2006/vcard/ns#' . shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
V: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | sub VX { return 'http://buzzword.org.uk/rdf/vcardx#' . shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
VX: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | sub RDF { return 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' . shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | ▶ | sub XSD { return 'http://www.w3.org/2001/XMLSchema#' . shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XSD: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sub flatten_node | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my $node = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | return $node->value if $node->is_resource || $node->is_literal; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | return $node->as_ntriples; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | our $VERSION = '0.012'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | our $PRODID = sprintf("+//IDN cpan.org//NONSGML %s v %s//EN", __PACKAGE__, $VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | our %dispatch = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | V('adr') => \&_prop_export_adr, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | V('n') => \&_prop_export_n, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | V('geo') => \&_prop_export_geo, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | V('org') => \&_prop_export_org, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | V('agent') => \&_prop_export_agent, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | V('tel') => \&_prop_export_typed, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | V('email') => \&_prop_export_typed, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | V('label') => \&_prop_export_typed, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | VX('impp') => \&_prop_export_typed, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | V('fax') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | V('homeAdr') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | V('homeTel') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | V('mobileEmail') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | V('mobileTel') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | V('personalEmail') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | V('unlabeledAdr') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | V('unlabeledEmail') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | V('unlabeledTel') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | V('workAdr') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | V('workEmail') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | V('workTel') => \&_prop_export_shortcut, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | V('photo') => \&_prop_export_binary, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | V('sound') => \&_prop_export_binary, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | V('logo') => \&_prop_export_binary, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | V('key') => \&_prop_export_binary, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | bless { %options }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | sub is_v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v4: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | return ($self->{vcard_version} =~ /4/) ? 4 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | sub is_v3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v3: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return $self->is_v4 ? 0 : 3; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | sub export_cards | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_cards: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my ($self, $model, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $model = rdf_parse($model) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
MC/DC0%0/2
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
builtin::blessed($model)
$model->isa("RDF::Trine::Model")
Truth table0%0/3
A and B
A= builtin::blessed($model)B= $model->isa("RDF::Trine::Model")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | unless blessed($model) && $model->isa('RDF::Trine::Model'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my @subjects = $model->subjects(rdf_resource(RDF('type')), rdf_resource(V('VCard'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | push @subjects, $model->subjects(rdf_resource(V('fn')), undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my %subjects = map { flatten_node($_) => $_ } @subjects; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my @cards; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | foreach my $s (values %subjects) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | push @cards, $self->export_card($model, $s, %options); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($options{sort}) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return sort { $a->entity_order cmp $b->entity_order } @cards; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return @cards; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | sub export_card | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_card: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my ($self, $model, $subject, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | $model = RDF::TrineShortcuts::rdf_parse($model) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
MC/DC0%0/2
builtin::blessed($model) and $model->isa("RDF::Trine::Model")
builtin::blessed($model)
$model->isa("RDF::Trine::Model")
Truth table0%0/3
A and B
A= builtin::blessed($model)B= $model->isa("RDF::Trine::Model")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | unless blessed($model) && $model->isa('RDF::Trine::Model'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $card = RDF::vCard->new_entity( profile=>'VCARD' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my %categories; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $triples = $model->get_statements($subject, undef, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | while (my $triple = $triples->next) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | unless (substr($triple->predicate->uri, 0, length(&V)) eq &V or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
substr($triple->predicate->uri, 0, length &V) eq &V or substr($triple->predicate->uri, 0, length &VX) eq &VX
MC/DC0%0/2
substr($triple->predicate->uri, 0, length &V) eq &V or substr($triple->predicate->uri, 0, length &VX) eq &VX
substr($triple->predicate->uri, 0, length &V) eq &V
substr($triple->predicate->uri, 0, length &VX) eq &VX
Truth table0%0/3
A or B
A= substr($triple->predicate->uri, 0, length &V) eq &VB= substr($triple->predicate->uri, 0, length &VX) eq &VX
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | substr($triple->predicate->uri, 0, length(&VX)) eq &VX); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if (defined $dispatch{$triple->predicate->uri} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
defined $RDF::vCard::Exporter::dispatch{$triple->predicate->uri} and ref $RDF::vCard::Exporter::dispatch{$triple->predicate->uri} eq "CODE"
MC/DC0%0/2
defined $RDF::vCard::Exporter::dispatch{$triple->predicate->uri} and ref $RDF::vCard::Exporter::dispatch{$triple->predicate->uri} eq "CODE"
defined $RDF::vCard::Exporter::dispatch{$triple->predicate->uri}
ref $RDF::vCard::Exporter::dispatch{$triple->predicate->uri} eq "CODE"
Truth table0%0/3
A and B
A= defined $RDF::vCard::Exporter::dispatch{$triple->predicate->uri}B= ref $RDF::vCard::Exporter::dispatch{$triple->predicate->uri} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | and ref($dispatch{$triple->predicate->uri}) eq 'CODE') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $code = $dispatch{$triple->predicate->uri}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $card->add($code->($self, $model, $triple)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ▶ | elsif ($triple->predicate->uri eq V('category') | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$triple->predicate->uri eq V("category") or $triple->predicate->uri eq VX("category")
MC/DC0%0/2
$triple->predicate->uri eq V("category") or $triple->predicate->uri eq VX("category")
$triple->predicate->uri eq V("category")
$triple->predicate->uri eq VX("category")
Truth table0%0/3
A or B
A= $triple->predicate->uri eq V("category")B= $triple->predicate->uri eq VX("category")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | or $triple->predicate->uri eq VX('category')) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $c = $self->_prop_extract_category($model, $triple); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $categories{$c}++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | elsif (! $triple->object->is_blank) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $card->add($self->_prop_export_simple($model, $triple)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (keys %categories) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $card->add( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | RDF::vCard::Line->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | property => 'categories', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | value => [[ sort keys %categories ]], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | $card->add( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | RDF::vCard::Line->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | property => 'version', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | value => $self->is_v4 ? '4.0' : '3.0', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | $card->add( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | RDF::vCard::Line->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | property => 'prodid', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | value => (defined $options{prodid} ? $options{prodid} : $PRODID), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | ) unless exists $options{prodid} && !defined $options{prodid}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
exists $options{"prodid"} and not defined $options{"prodid"}
MC/DC0%0/2
exists $options{"prodid"} and not defined $options{"prodid"}
exists $options{"prodid"}
not defined $options{"prodid"}
Truth table0%0/3
A and not(B)
A= exists $options{"prodid"}B= not defined $options{"prodid"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $card->add( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | RDF::vCard::Line->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | property => 'source', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | value => $options{source}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | type_parameters => {value=>'URI'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | ) if defined $options{source}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return $card; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | my %dtmap = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | XSD('anyURI') => 'URI', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | XSD('string') => 'TEXT', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | XSD('integer') => 'INTEGER', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | XSD('date') => 'DATE', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | XSD('dateTime') => 'DATE-TIME', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | XSD('duration') => 'DURATION', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 'urn:iso:std:iso:8601#timeInterval' => 'PERIOD', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | XSD('decimal') => 'FLOAT', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # BOOLEAN ? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | sub _prop_export_simple | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_simple: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $prop = 'x-data'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($triple->predicate->uri =~ m/([^\#\/]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $prop = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $val = flatten_node($triple->object); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $params = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ($triple->object->is_literal | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/6
$triple->object->is_literal and $triple->object->has_datatype and defined $dtmap{$triple->object->literal_datatype}
$triple->object->is_literal and $triple->object->has_datatype
MC/DC0%0/3
$triple->object->is_literal and $triple->object->has_datatype and defined $dtmap{$triple->object->literal_datatype}
$triple->object->is_literal
$triple->object->has_datatype
defined $dtmap{$triple->object->literal_datatype}
Truth table0%0/4
A and B and C
A= $triple->object->is_literalB= $triple->object->has_datatypeC= defined $dtmap{$triple->object->literal_datatype}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | and $triple->object->has_datatype | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | and defined $dtmap{ $triple->object->literal_datatype }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $params = { value => $dtmap{ $triple->object->literal_datatype } }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ▶ | elsif ($triple->object->is_literal | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$triple->object->is_literal and $triple->object->has_language
MC/DC0%0/2
$triple->object->is_literal and $triple->object->has_language
$triple->object->is_literal
$triple->object->has_language
Truth table0%0/3
A and B
A= $triple->object->is_literalB= $triple->object->has_language
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | and $triple->object->has_language) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $params = { value=>'TEXT', language=>$triple->object->literal_value_language }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | elsif ($triple->object->is_resource) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $params = { value=>'URI' }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | property => $prop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | value => $val, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | type_parameters => $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | sub _prop_export_adr | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_adr: not called CC=14 SCAR=53.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $adr = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | foreach my $part (qw(post-office-box extended-address street-address locality | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | region postal-code country-name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my @objects = $model->objects($triple->object, rdf_resource(V($part))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | push @$adr, [ map { flatten_node($_) } @objects ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my $params = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $types = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | unless ($triple->object->is_literal) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my @types = $model->objects($triple->object, rdf_resource(RDF('type'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | push @types, $model->objects($triple->object, rdf_resource(VX('usage'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | foreach my $type (@types) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($type->is_resource and $type->uri =~ m/([^\#\/]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$type->is_resource and $type->uri =~ m[([^\#/]+)$]
MC/DC0%0/2
$type->is_resource and $type->uri =~ m[([^\#/]+)$]
$type->is_resource
$type->uri =~ m[([^\#/]+)$]
Truth table0%0/3
A and B
A= $type->is_resourceB= $type->uri =~ m[([^\#/]+)$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $types->{ uc $1 } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | elsif ($type->is_literal) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $types->{ uc $type->literal_value } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | delete $types->{TEL}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | delete $types->{EMAIL}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | delete $types->{IMPP}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | delete $types->{ADDRESS}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | delete $types->{LABEL}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my @geos; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $iter = $model->get_statements($triple->object, rdf_resource(VX('geo')), undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | while (my $st = $iter->next) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $gline = $self->_prop_export_geo($model, $st); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | push @geos, $gline->_unescape_value($gline->value_to_string); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if (@geos) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $params->{geo} = \@geos; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (%$types and $self->is_v4) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
%$types and $self->is_v4
MC/DC0%0/2
%$types and $self->is_v4
%$types
$self->is_v4
Truth table0%0/3
A and B
A= %$typesB= $self->is_v4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $params->{type} = [sort grep { !/^pref$/i } keys %$types]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | $params->{pref} = 1 if $types->{PREF}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | elsif (%$types) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $params->{type} = [sort keys %$types]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | $params = undef unless %$params; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | property => 'adr', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | value => $adr, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | type_parameters => $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | sub _prop_export_n | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_n: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $n = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | foreach my $part (qw(family-name given-name additional-name honorific-prefix honorific-suffix)) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my @objects = $model->objects($triple->object, rdf_resource(V($part))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | push @$n, [ map { flatten_node($_) } @objects ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | property => 'n', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | value => $n, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | sub _prop_export_agent | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_agent: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if ($triple->object->is_literal) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | property => 'agent', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | value => flatten_node($triple->object), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | type_parameters => { value=>'TEXT' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $agent = $self->export_card($model, $triple->object); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | property => 'agent', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | value => $agent->to_string, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | type_parameters => { value=>'VCARD' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | sub _prop_export_org | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_org: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # Note: W3C Member Submission is inconsistent with regards to organiSation/organiZation. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my @objects = $model->objects_for_predicate_list($triple->object, rdf_resource(V('organization-name')), rdf_resource(V('organisation-name'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my @values = map { flatten_node($_) } grep {$_->is_literal} @objects; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my $org = [ ($values[0] || '') ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$values[0] || ''
MC/DC0%0/1
$values[0] || ''
$values[0]
Truth table0%0/2
A
A= $values[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | @objects = $model->objects_for_predicate_list($triple->object, rdf_resource(V('organization-unit')), rdf_resource(V('organisation-unit'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | push @$org, map { flatten_node($_) } grep {$_->is_literal} @objects; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | property => 'org', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | value => $org, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | sub _prop_export_geo | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_geo: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $g = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | foreach my $part (qw(latitude longitude)) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my @objects = $model->objects($triple->object, rdf_resource(V($part))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my @values = map { flatten_node($_) } grep {$_->is_literal} @objects; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | push @$g, ($values[0] || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$values[0] || ''
MC/DC0%0/1
$values[0] || ''
$values[0]
Truth table0%0/2
A
A= $values[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ($self->is_v4) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | property => 'geo', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | value => sprintf('geo:%f,%f', @$g), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | type_parameters => { value=>'URI' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | property => 'geo', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | value => $g, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | type_parameters => { value=>'TEXT' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # tel, email, label and impp may be typed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | sub _prop_export_typed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_typed: not called CC=28 SCAR=67.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $value_node = $triple->object; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | unless ($value_node->is_literal) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my @objects = $model->objects($value_node, rdf_resource(RDF('value'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | foreach my $o (@objects) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | unless ($o->is_blank) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $value_node = $o; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $value = flatten_node($value_node); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $prop = 'x-data'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ($triple->predicate->uri =~ m/([^\#\/]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $prop = lc $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $types = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $params = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ($prop eq 'email' and $value =~ /^mailto:(.+)$/i) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$prop eq "email" and $value =~ /^mailto:(.+)$/i
MC/DC0%0/2
$prop eq "email" and $value =~ /^mailto:(.+)$/i
$prop eq "email"
$value =~ /^mailto:(.+)$/i
Truth table0%0/3
A and B
A= $prop eq "email"B= $value =~ /^mailto:(.+)$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $value = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $types->{INTERNET} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ▶ | elsif ($prop eq 'tel' and $value =~ /^(tel|fax|modem):(.+)$/i) | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$prop eq "tel" and $value =~ /^(tel|fax|modem):(.+)$/i
MC/DC0%0/2
$prop eq "tel" and $value =~ /^(tel|fax|modem):(.+)$/i
$prop eq "tel"
$value =~ /^(tel|fax|modem):(.+)$/i
Truth table0%0/3
A and B
A= $prop eq "tel"B= $value =~ /^(tel|fax|modem):(.+)$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if ($self->is_v4) #v4 telephone numbers are URIs | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $params = { value=>'URI' }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | else #v3 telephone numbers are text (well VALUE=PHONE-NUMBER technically) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $value = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | $types->{FAX} = 1 if lc $1 eq 'fax'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | $types->{MODEM} = 1 if lc $1 eq 'modem'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | elsif ($value_node->is_resource) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $params = { value=>'URI' }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | unless ($triple->object->is_literal) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my @types = $model->objects($triple->object, rdf_resource(RDF('type'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | push @types, $model->objects($triple->object, rdf_resource(VX('usage'))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | foreach my $type (@types) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | if ($type->is_resource and $type->uri =~ m/([^\#\/]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$type->is_resource and $type->uri =~ m[([^\#/]+)$]
MC/DC0%0/2
$type->is_resource and $type->uri =~ m[([^\#/]+)$]
$type->is_resource
$type->uri =~ m[([^\#/]+)$]
Truth table0%0/3
A and B
A= $type->is_resourceB= $type->uri =~ m[([^\#/]+)$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $types->{ uc $1 } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | elsif ($type->is_literal) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $types->{ uc $type->literal_value } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | delete $types->{TEL}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | delete $types->{EMAIL}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | delete $types->{IMPP}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | delete $types->{ADDRESS}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | delete $types->{LABEL}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | if (%$types and $self->is_v4) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
%$types and $self->is_v4
MC/DC0%0/2
%$types and $self->is_v4
%$types
$self->is_v4
Truth table0%0/3
A and B
A= %$typesB= $self->is_v4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $params->{type} = [sort grep { !/^pref$/i } keys %$types]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | $params->{pref} = 1 if $types->{PREF}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | elsif (%$types) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $params->{type} = [sort keys %$types]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | $params = undef unless %$params; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | if ($prop eq 'tel') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | $params->{'value'} ||= 'PHONE-NUMBER'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params->{"value"} ||= "PHONE-NUMBER"
MC/DC0%0/1
$params->{"value"} ||= "PHONE-NUMBER"
$params->{"value"}
Truth table0%0/2
A
A= $params->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if ($self->is_v4 and $params->{'value'} ne 'URI' and $value =~ /^\+[0-9\s\-]+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->is_v4 and $params->{"value"} ne "URI" and $value =~ /^\+[0-9\s\-]+$/
$self->is_v4 and $params->{"value"} ne "URI"
MC/DC0%0/3
$self->is_v4 and $params->{"value"} ne "URI" and $value =~ /^\+[0-9\s\-]+$/
$self->is_v4
$params->{"value"} ne "URI"
$value =~ /^\+[0-9\s\-]+$/
Truth table0%0/4
A and B and C
A= $self->is_v4B= $params->{"value"} ne "URI"C= $value =~ /^\+[0-9\s\-]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $value =~ s/\s/-/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $value = "tel:${value}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $params->{'value'} = 'URI'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | return RDF::vCard::Line->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | property => $prop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | value => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | type_parameters => $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | sub _prop_export_shortcut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_shortcut: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $shortcuts = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | V('fax') => [V('tel') => ['FAX']], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | V('homeAdr') => [V('adr') => ['HOME']], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | V('homeTel') => [V('tel') => ['HOME']], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | V('mobileEmail') => [V('email') => undef], # EMAIL;TYPE=CELL not allowed by RFC 2426 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | V('mobileTel') => [V('tel') => ['CELL']], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | V('personalEmail') => [V('email') => undef], # RFC 2426 doesn't define TYPE=PERSONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | V('unlabeledAdr') => [V('adr') => undef], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | V('unlabeledEmail') => [V('email') => undef], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | V('unlabeledTel') => [V('tel') => undef], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | V('workAdr') => [V('adr') => ['WORK']], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | V('workEmail') => [V('email') => undef], # EMAIL;TYPE=WORK not allowed by RFC 2426 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | V('workTel') => [V('tel') => ['WORK']], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if (exists $shortcuts->{$triple->predicate->uri}) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ($property_uri, $types) = @{ $shortcuts->{$triple->predicate->uri} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if (defined $dispatch{$property_uri} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $RDF::vCard::Exporter::dispatch{$property_uri} and ref $RDF::vCard::Exporter::dispatch{$property_uri} eq "CODE"
MC/DC0%0/2
defined $RDF::vCard::Exporter::dispatch{$property_uri} and ref $RDF::vCard::Exporter::dispatch{$property_uri} eq "CODE"
defined $RDF::vCard::Exporter::dispatch{$property_uri}
ref $RDF::vCard::Exporter::dispatch{$property_uri} eq "CODE"
Truth table0%0/3
A and B
A= defined $RDF::vCard::Exporter::dispatch{$property_uri}B= ref $RDF::vCard::Exporter::dispatch{$property_uri} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | and ref($dispatch{$property_uri}) eq 'CODE') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $code = $dispatch{$property_uri}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $line = $code->($self, $model, $triple); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | elsif (! $triple->object->is_blank) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $line = $self->_prop_export_simple($model, $triple); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if ($line) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | push @{ $line->type_parameters->{type} }, @$types; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | sub _prop_export_binary | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_export_binary: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $line = $self->_prop_export_simple($model, $triple); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if ($self->is_v3 and $line->value->[0] =~ /^data:\S+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->is_v3 and $line->value->[0] =~ /^data:\S+$/
MC/DC0%0/2
$self->is_v3 and $line->value->[0] =~ /^data:\S+$/
$self->is_v3
$line->value->[0] =~ /^data:\S+$/
Truth table0%0/3
A and B
A= $self->is_v3B= $line->value->[0] =~ /^data:\S+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my $data_uri = URI->new( $line->value->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my $data = $data_uri->data; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $medium = $data_uri->media_type; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $line->value->[0] = MIME::Base64::encode_base64($data, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $line->type_parameters->{value} = 'BINARY'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $line->type_parameters->{encoding} = 'B'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | $line->type_parameters->{type} = [ uc($1) ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | if $medium =~ m'^image/([a-z0-9\_\-\+]+)'i; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | $line->type_parameters->{fmtype} = $medium | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | if $medium =~ m'.+/.+'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | sub _prop_extract_category | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prop_extract_category: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my ($self, $model, $triple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | if ($triple->object->is_literal) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | return uc $triple->object->literal_value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | my @labels = grep | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | { $_->is_literal } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | $model->objects_for_predicate_list( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | $triple->object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | rdf_resource('http://www.w3.org/2004/02/skos/core#prefLabel'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | rdf_resource('http://www.holygoat.co.uk/owl/redwood/0.1/tags/name'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | rdf_resource('http://www.w3.org/2000/01/rdf-schema#label'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | rdf_resource('http://www.w3.org/2004/02/skos/core#altLabel'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | rdf_resource('http://www.w3.org/2004/02/skos/core#notation'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | rdf_resource(RDF('value')), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | if (@labels) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | return uc $labels[0]->literal_value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | elsif ($triple->object->is_resource) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | return $triple->object->uri; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||