lib/OWL/Data/OWL/Class.pm

filter: Statementstmt 90.3% 47 / 52 Branchbran 71.4% 10 / 14 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 81.2% 13 / 16 Podpod 100% 2 / 2 totaltotal 77.7% 77 / 99 CC 11 SCAR 14.2
CC
11
Cov
81%
__ANON__
9.6
_attr_prop
3.5
_accessible
2.0
CRAP 4.1
« blib/script/owl2perl-generate-modules.pl ↑ Summary lib/OWL/Data/OWL/ObjectProperty.pm »
1 #-----------------------------------------------------------------
2 # OWL::Data::OWL::Class
3 # Author: Edward Kawas <edward.kawas@gmail.com>,
4 # For copyright and disclaimer see below.
5 #
6 # $Id: Class.pm,v 1.11 2010-02-10 23:19:11 ubuntu Exp $
7 #-----------------------------------------------------------------
8 package OWL::Data::OWL::Class;
9 2 ▶use base ("OWL::Base");
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
12
13 # imports
14 2 ▶use RDF::Core::Statement;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use RDF::Core::Model;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use RDF::Core::Storage::Memory;
Subroutine BEGIN: called CC=1 SCAR=0.0
17
18 # add versioning to this module
19 2 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 $VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /: (\d+)\.(\d+)/;
21
22 =head1 NAME
23
24 OWL::Data::OWL::Class
25
26 =head1 SYNOPSIS
27
28 use OWL::Data::OWL::Class;
29
30 # create an owl class
31 my $data = OWL::Data::OWL::Class->new ();
32
33
34 =head1 DESCRIPTION
35
36 An object representing an OWL class
37
38 =head1 AUTHORS
39
40 Edward Kawas (edward.kawas [at] gmail [dot] com)
41
42 =cut
43
44 #-----------------------------------------------------------------
45 # A list of allowed attribute names. See OWL::Base for details.
46 #-----------------------------------------------------------------
47
48 =head1 ACCESSIBLE ATTRIBUTES
49
50 Details are in L<OWL::Base>. Here just a list of them:
51
52 =over
53
54 =item B<label> an optional RDF label for this class
55
56 =item B<type> a URI that describes the type of this class
57
58 =item B<value> a URI to an individual of this class (same as uri, e.g. if you set this, you set value too)
59
60 =item B<uri> a URI to an individual of this class (same as value, e.g. if you set this, you set uri too)
61
62 =item B<strict> a boolean value that determines whether or not to enforce class constraints. Default is false.
63
64 =back
65
66 =cut
67
68 {
69 my %_allowed = (
70 # the RDFS label for this node
71 label => { type => OWL::Base->STRING },
72 type => { type => OWL::Base->STRING },
73 # value and uri are synonyms here
74 value => {
75 type => OWL::Base->STRING,
76 4 ▶ post => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
77 4 my $self = shift;
78 4 $self->{uri} = $self->value;
79 # set the id portion of the ID
80 4 $self->ID($self->{value});
81 }
82 },
83 # value and uri are synonyms here
84 uri => {
85 type => OWL::Base->STRING,
86 2 ▶ post => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
87 2 my $self = shift;
88 2 $self->{value} = $self->uri;
89 # set the id portion of the ID
90 2 $self->ID($self->{value});
91 }
92 },
93 ID => {
94 type => OWL::Base->STRING,
95 6 ▶ post => sub {
Subroutine __ANON__: called CC=8 SCAR=22.6
96 6 my $self = shift;
97 6 my $id = undef;
98 # id is either text after leftmost :
99 6 ▶ $id = $1 if ($self->{ID} =~ m|.*/\w+:(.*)$|gi);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ID"} =~ m[.*/\w+:(.*)$]gi 2 4 6
100 # or item after #
101 6 ▶ $id = $1 if not defined $id and ($self->{ID} =~ m|#(.*)$|gi);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $id and $self->{"ID"} =~ /#(.*)$/gi 4 2 6
Condition66%2/3
not defined $id and $self->{"ID"} =~ /#(.*)$/gi
!ll&&!rl&&r
204
MC/DC50%1/2
not defined $id and $self->{"ID"} =~ /#(.*)$/gi
not defined $id $self->{"ID"} =~ /#(.*)$/gi
Truth table66%2/3
not(A) and B
A= not defined $idB= $self->{"ID"} =~ /#(.*)$/gi
ABresult
0X0
100
111
102 # or item after /
103 6 ▶ $id = $1 if not defined $id and ($self->{ID} =~ m|.*/(.*)$|gi);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $id and $self->{"ID"} =~ m[.*/(.*)$]gi 0 6 6
Condition33%1/3
not defined $id and $self->{"ID"} =~ m[.*/(.*)$]gi
!ll&&!rl&&r
600
MC/DC0%0/2
not defined $id and $self->{"ID"} =~ m[.*/(.*)$]gi
not defined $id $self->{"ID"} =~ m[.*/(.*)$]gi
Truth table33%1/3
not(A) and B
A= not defined $idB= $self->{"ID"} =~ m[.*/(.*)$]gi
ABresult
0X0
100
111
104 6 ▶ $id = $1 if not defined $id and ($self->{ID} =~ m|^\s*([[:alnum:]]+)\s*$|gi);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $id and $self->{"ID"} =~ /^\s*([[:alnum:]]+)\s*$/gi 0 6 6
Condition33%1/3
not defined $id and $self->{"ID"} =~ /^\s*([[:alnum:]]+)\s*$/gi
!ll&&!rl&&r
600
MC/DC0%0/2
not defined $id and $self->{"ID"} =~ /^\s*([[:alnum:]]+)\s*$/gi
not defined $id $self->{"ID"} =~ /^\s*([[:alnum:]]+)\s*$/gi
Truth table33%1/3
not(A) and B
A= not defined $idB= $self->{"ID"} =~ /^\s*([[:alnum:]]+)\s*$/gi
ABresult
0X0
100
111
105 6 $self->{ID} = $id;
106 }
107 },
108 2 strict => {type => OWL::Base->BOOLEAN,},
109 # used internally / set during _get_statements
110 subject => { type => 'RDF::Core::Resource' },
111 model => { type => 'RDF::Core::Model' },
112 );
113
114 258 ▶ sub _accessible {
Subroutine _accessible: called CC=2 SCAR=6.9
115 258 my ( $self, $attr ) = @_;
116 258 ▶ exists $_allowed{$attr} or $self->SUPER::_accessible($attr);
Branch: 1 branch
BranchTrueFalseTotal
exists $_allowed{$attr} or $self->SUPER::_accessible($attr) 114 144 258
117 }
118
119 104 ▶ sub _attr_prop {
Subroutine _attr_prop: called CC=3 SCAR=12.5
120 104 my ( $self, $attr_name, $prop_name ) = @_;
121 104 my $attr = $_allowed{$attr_name};
122 104 ▶ return ref($attr) ? $attr->{$prop_name} : $attr if $attr;
Branch: 2 branches
BranchTrueFalseTotal
if $attr 104 0 104
ref $attr ? : 104 0 104
123 0 return $self->SUPER::_attr_prop( $attr_name, $prop_name );
124 }
125 }
126
127 #-----------------------------------------------------------------
128
129 =head1 SUBROUTINES
130
131 =cut
132
133 #-----------------------------------------------------------------
134 # init
135 #-----------------------------------------------------------------
136 2 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
137 11 my ($self) = shift;
138 11 $self->SUPER::init();
139 11 $self->strict(0);
140 11 $self->model(new RDF::Core::Model( Storage => new RDF::Core::Storage::Memory ));
141 }
142
143 #-------------------------------------------------------------------
144 # get an RDF::Core::Enumerator object or undef if there are no statements
145 #-------------------------------------------------------------------
146 0 ▶sub _get_statements {
Subroutine _get_statements: not called CC=1 SCAR=6.9
147 0 return undef;
148 }
149
150 #-------------------------------------------------------------------
151 # returns a hash reference with possible keys: datatypes, objects
152 #-------------------------------------------------------------------
153 0 ▶sub __properties {
Subroutine __properties: not called CC=1 SCAR=6.9
154 0 return {};
155 }
156
157 =head2 clear_statements
158
159 clear_statements: clears statements from class; however, this does not remove properties.
160
161 =cut
162
163 0 ▶sub clear_statements {
Subroutine clear_statements: not called CC=1 SCAR=6.9
Pod documented
164 0 my ($self) = shift;
165 0 $self->model(new RDF::Core::Model( Storage => new RDF::Core::Storage::Memory ));
166 }
167
168
169
170 2 1;
171 __END__
« blib/script/owl2perl-generate-modules.pl ↑ Summary lib/OWL/Data/OWL/ObjectProperty.pm »