line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
3
|
|
|
|
|
|
|
our $VERSION = '0.105'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Moose; |
6
|
2
|
|
|
2
|
|
1106
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
7
|
|
|
|
|
|
|
use Carp; |
8
|
2
|
|
|
2
|
|
11219
|
use RDF::DOAP::Types -types; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
145
|
|
9
|
2
|
|
|
2
|
|
11
|
use RDF::DOAP::Utils -traits; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
15
|
|
10
|
2
|
|
|
2
|
|
12231
|
use Scalar::Util qw( weaken refaddr ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
11
|
2
|
|
|
2
|
|
542
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
96
|
|
12
|
|
|
|
|
|
|
use RDF::Trine::Namespace qw(rdf rdfs owl xsd); |
13
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
14
|
|
|
|
|
|
|
has rdf_about => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => Identifier, |
17
|
|
|
|
|
|
|
coerce => 1, |
18
|
|
|
|
|
|
|
predicate => 'has_rdf_about', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has rdf_model => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => Model, |
24
|
|
|
|
|
|
|
predicate => 'has_rdf_model', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has rdf_type => ( |
28
|
|
|
|
|
|
|
traits => [ WithURI ], |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => ArrayRef[Identifier], |
31
|
|
|
|
|
|
|
coerce => 1, |
32
|
|
|
|
|
|
|
uri => $rdf->type, |
33
|
|
|
|
|
|
|
multi => 1, |
34
|
|
|
|
|
|
|
default => sub { [] }, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has $_ => ( |
38
|
|
|
|
|
|
|
traits => [ WithURI ], |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
isa => String, |
41
|
|
|
|
|
|
|
coerce => 1, |
42
|
|
|
|
|
|
|
uri => $rdfs->$_, |
43
|
|
|
|
|
|
|
) for qw( label comment ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has see_also => ( |
46
|
|
|
|
|
|
|
traits => [ WithURI ], |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => ArrayRef[Identifier], |
49
|
|
|
|
|
|
|
coerce => 1, |
50
|
|
|
|
|
|
|
uri => $rdfs->seeAlso, |
51
|
|
|
|
|
|
|
multi => 1, |
52
|
|
|
|
|
|
|
lazy => 1, |
53
|
|
|
|
|
|
|
default => sub { |
54
|
|
|
|
|
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
if ($self->has_rdf_about && $self->rdf_about =~ /^tdb:[^:]*:(.*)$/) |
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
return [ Identifier->coerce($1) ]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
return []; |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
our $MODEL; |
64
|
|
|
|
|
|
|
my %objects; |
65
|
|
|
|
|
|
|
{ |
66
|
|
|
|
|
|
|
my $class = shift; |
67
|
|
|
|
|
|
|
my $identifier = Identifier->assert_coerce( $_[0] ); |
68
|
42
|
|
|
42
|
0
|
25006
|
|
69
|
42
|
|
|
|
|
103
|
my $model = $_[1] ? Model->assert_return( $_[1] ) : $MODEL or die; |
70
|
|
|
|
|
|
|
|
71
|
42
|
100
|
|
|
|
2269
|
return $objects{ refaddr($model) }{ $identifier } |
|
|
50
|
|
|
|
|
|
72
|
|
|
|
|
|
|
if $objects{ refaddr($model) }{ $identifier }; |
73
|
|
|
|
|
|
|
|
74
|
42
|
100
|
|
|
|
196
|
my (%attr, %multi); |
75
|
|
|
|
|
|
|
for my $a ($class->meta->get_all_attributes) |
76
|
32
|
|
|
|
|
357
|
{ |
77
|
32
|
|
|
|
|
142
|
$a->does(WithURI) or next; |
78
|
|
|
|
|
|
|
$attr{ $a->uri } = $a->init_arg || $a->name; |
79
|
346
|
100
|
|
|
|
17147
|
$multi{ $a->uri } = $a->multi; |
80
|
262
|
|
33
|
|
|
59664
|
} |
81
|
262
|
|
|
|
|
19266
|
|
82
|
|
|
|
|
|
|
my %args = ( |
83
|
|
|
|
|
|
|
rdf_about => $identifier, |
84
|
32
|
|
|
|
|
1538
|
rdf_model => $model, |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
my $iter = $model->get_statements($identifier, undef, undef); |
87
|
|
|
|
|
|
|
while (my $st = $iter->next) |
88
|
32
|
|
|
|
|
99
|
{ |
89
|
32
|
|
|
|
|
87130
|
my $name = $attr{ $st->predicate } or next; |
90
|
|
|
|
|
|
|
|
91
|
138
|
100
|
|
|
|
14349
|
if ($multi{ $st->predicate }) |
92
|
|
|
|
|
|
|
{ |
93
|
111
|
100
|
|
|
|
1644
|
push @{ $args{$name} ||= [] }, $st->object; |
94
|
|
|
|
|
|
|
} |
95
|
58
|
|
100
|
|
|
729
|
else |
|
58
|
|
|
|
|
247
|
|
96
|
|
|
|
|
|
|
{ |
97
|
|
|
|
|
|
|
$args{$name} ||= $st->object; |
98
|
|
|
|
|
|
|
} |
99
|
53
|
|
33
|
|
|
790
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
local $MODEL = $model; |
102
|
|
|
|
|
|
|
my $self = $objects{ refaddr($model) }{ $identifier } = $class->new(%args); |
103
|
32
|
|
|
|
|
1244
|
weaken($objects{ refaddr($model) }{ $identifier }); |
104
|
32
|
|
|
|
|
165
|
return $self; |
105
|
32
|
|
|
|
|
49222
|
} |
106
|
32
|
|
|
|
|
790
|
|
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
my $self = shift; |
109
|
|
|
|
|
|
|
croak "This object cannot rdf_get; stopped" |
110
|
|
|
|
|
|
|
unless $self->has_rdf_model && $self->has_rdf_about; |
111
|
0
|
|
|
0
|
0
|
0
|
|
112
|
0
|
0
|
0
|
|
|
0
|
my @values = $self->rdf_model->objects_for_predicate_list($self->rdf_about, @_); |
113
|
|
|
|
|
|
|
wantarray ? @values : $values[0]; |
114
|
|
|
|
|
|
|
} |
115
|
0
|
|
|
|
|
0
|
|
116
|
0
|
0
|
|
|
|
0
|
{ |
117
|
|
|
|
|
|
|
my $self = shift; |
118
|
|
|
|
|
|
|
my @values = grep $_->is_literal, $self->rdf_get(@_); |
119
|
|
|
|
|
|
|
wantarray ? @values : $values[0]; |
120
|
|
|
|
|
|
|
} |
121
|
0
|
|
|
0
|
0
|
0
|
|
122
|
0
|
|
|
|
|
0
|
{ |
123
|
0
|
0
|
|
|
|
0
|
my $self = shift; |
124
|
|
|
|
|
|
|
my @values = grep $_->is_resource, $self->rdf_get(@_); |
125
|
|
|
|
|
|
|
wantarray ? @values : $values[0]; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
0
|
0
|
{ |
129
|
0
|
|
|
|
|
0
|
my $self = shift; |
130
|
0
|
0
|
|
|
|
0
|
$self->fixes if $self->can('fixes'); |
131
|
|
|
|
|
|
|
my $hash = +{ %$self }; |
132
|
|
|
|
|
|
|
delete $hash->{$_} for qw( rdf_about rdf_model ); |
133
|
|
|
|
|
|
|
for my $k (keys %$hash) { |
134
|
|
|
|
|
|
|
if (blessed $hash->{$k} and $hash->{$k}->isa('RDF::Trine::Node')) { |
135
|
0
|
|
|
0
|
0
|
0
|
$hash->{$k} = $hash->{$k}->as_ntriples; |
136
|
0
|
0
|
|
|
|
0
|
} |
137
|
0
|
|
|
|
|
0
|
if (ref $hash->{$k} eq 'ARRAY') { |
138
|
0
|
|
|
|
|
0
|
$hash->{$k} = [ map { |
139
|
0
|
|
|
|
|
0
|
(blessed $_ and $_->isa('RDF::Trine::Node')) ? $_->as_ntriples : $_ |
140
|
0
|
0
|
0
|
|
|
0
|
} @{ $hash->{$k} } ]; |
141
|
0
|
|
|
|
|
0
|
} |
142
|
|
|
|
|
|
|
} |
143
|
0
|
0
|
|
|
|
0
|
$hash->{'@'} = $self->rdf_about->as_ntriples if $self->has_rdf_about; |
144
|
|
|
|
|
|
|
# $hash->{__ISA__} = [ $self->meta->linearized_isa ]; |
145
|
0
|
0
|
0
|
|
|
0
|
# $hash->{__DOES__} = [ map $_->name, $self->meta->calculate_all_roles_with_inheritance ]; |
146
|
0
|
|
|
|
|
0
|
return $hash; |
|
0
|
|
|
|
|
0
|
|
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
0
|
{ |
150
|
|
|
|
|
|
|
require JSON; |
151
|
|
|
|
|
|
|
JSON::to_json( |
152
|
0
|
|
|
|
|
0
|
shift(), |
153
|
|
|
|
|
|
|
{ pretty => 1, canonical => 1, convert_blessed => 1 }, |
154
|
|
|
|
|
|
|
); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
0
|
0
|
0
|
{ |
158
|
0
|
|
|
|
|
0
|
my $self = shift; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
return grep($_[0]->equal($_), @{$self->rdf_type}) |
161
|
|
|
|
|
|
|
if Identifier->check(@_); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$self->SUPER::isa(@_); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
193
|
|
|
193
|
0
|
31033
|
1; |