lib/OWL/Data/Def/DatatypeProperty.pm

filter: Statementstmt 86.4% 32 / 37 Branchbran 44.4% 8 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 1 / 1 totaltotal 75.3% 49 / 65 CC 10 SCAR 13.8
CC
10
Cov
73%
__ANON__
12.0
__ANON__
3.1
__ANON__
3.1
CRAP 4.0
« lib/OWL/Data/OWL/ObjectProperty.pm ↑ Summary lib/OWL/Data/Def/ObjectProperty.pm »
1 #-----------------------------------------------------------------
2 # OWL::Data::Def::DatatypeProperty
3 # Author: Edward Kawas <edward.kawas@gmail.com>,
4 # For copyright and disclaimer see below.
5 #
6 # $Id: DatatypeProperty.pm,v 1.8 2010-01-07 21:48:08 ubuntu Exp $
7 #-----------------------------------------------------------------
8 package OWL::Data::Def::DatatypeProperty;
9 2 ▶use base qw( OWL::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 # add versioning to this module
13 2 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 $VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /: (\d+)\.(\d+)/;
15
16 =head1 NAME
17
18 OWL::Data::Def::DatatypeProperty - definition of an owl datatype property
19
20 =head1 SYNOPSIS
21
22 use OWL::Data::Def::DatatypeProperty;
23
24 # create a new data type
25 my $datatype = new OWL::Data::Def::DatatypeProperty
26 ( name => 'MySequenceProperty',
27 domain => 'http://some.domain.com/MySequenceDomain',
28 uri => 'http://some.domain.com/MySequenceProperty',
29 range => 'http://some.domain.com/MySequence',
30 parent => 'http://some.domain.com/MySequencePropertyParent',
31 );
32
33 # get the name of this datatype property
34 print $datatype->name;
35
36
37 =cut
38
39 =head1 DESCRIPTION
40
41 A container representing an OWL datatype property definition
42
43 =head1 AUTHORS
44
45 Edward Kawas (edward.kawas [at] gmail [dot] com)
46
47 =cut
48
49 #-----------------------------------------------------------------
50 # A list of allowed attribute names. See OWL::Base for details.
51 #-----------------------------------------------------------------
52
53 =head1 ACCESSIBLE ATTRIBUTES
54
55 Details are in L<OWL::Base>. Here just a list of them:
56
57 =over
58
59 =item B<name>
60
61 A name of this datatype property
62
63 =item B<parent>
64
65 A parent for this datatype property ... defaults to OWL::Data::OWL::DatatypeProperty
66
67 =item B<domain>
68
69 The domain of this datatype property
70
71 =item B<range>
72
73 The range of this datatype property
74
75 =item B<uri>
76
77 The uri of this datatype property
78
79 =back
80
81 =cut
82
83 {
84 my %_allowed = (
85 uri => {
86 type => OWL::Base->STRING,
87 10 ▶ post => sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
88 10 my ($self) = shift;
89 10 my $package =
90 $self->oProperty2module( $self->uri2package( $self->uri ) );
91 10 $self->{module_name} = $package;
92
93 # extract our name and set it
94 10 ▶ my $name = $1 if $package =~ m|\:\:(\w+)$|gi;
Branch: 1 branch
BranchTrueFalseTotal
if $package =~ /\:\:(\w+)$/gi 10 0 10
95 10 ▶ $name = $package unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 10 10
96 10 $self->{name} = $name;
97 }
98 },
99 parent => {
100 type => OWL::Base->STRING,
101 20 ▶ post => sub {
Subroutine __ANON__: called CC=3 SCAR=11.4
102 20 my ($self) = shift;
103 20 my $name = $self->parent;
104 $self->{module_parent} =
105 $self->oProperty2module(
106 $self->uri2package( $self->{parent} ) )
107 20 ▶ unless $self->{parent} eq 'OWL::Data::OWL::DatatypeProperty';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"parent"} eq "OWL::Data::OWL::DatatypeProperty" 0 20 20
108 $self->{module_parent} = $self->{parent}
109 20 ▶ if $self->{parent} eq 'OWL::Data::OWL::DatatypeProperty';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parent"} eq "OWL::Data::OWL::DatatypeProperty" 20 0 20
110 },
111 },
112 domain => { type => OWL::Base->STRING, },
113 name => {
114 type => OWL::Base->STRING,
115 0 ▶ post => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
116 0 my ($self) = shift;
117 my $package =
118 0 $self->oProperty2module( $self->uri2package( $self->{name} ) );
119 # extract our name and set it
120 0 ▶ my $name = $1 if $package =~ m|\:\:(\w+)$|gi;
Branch: 1 branch
BranchTrueFalseTotal
if $package =~ /\:\:(\w+)$/gi 0 0 0
121 0 ▶ $name = $package unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
122 0 $self->{name} = $name;
123 }
124 },
125 2 range => { type => OWL::Base->STRING, },
126
127 # used internally (but cannot start with underscore - Template would ignore them)
128 module_name => undef,
129 module_parent => undef,
130 );
131
132 14 ▶ sub _accessible {
Subroutine _accessible: called CC=2 SCAR=7.2
133 14 my ( $self, $attr ) = @_;
134 14 ▶ exists $_allowed{$attr} or $self->SUPER::_accessible($attr);
Branch: 1 branch
BranchTrueFalseTotal
exists $_allowed{$attr} or $self->SUPER::_accessible($attr) 14 0 14
135 }
136
137 56 ▶ sub _attr_prop {
Subroutine _attr_prop: called CC=3 SCAR=11.0
138 56 my ( $self, $attr_name, $prop_name ) = @_;
139 56 my $attr = $_allowed{$attr_name};
140 56 ▶ return ref($attr) ? $attr->{$prop_name} : $attr if $attr;
Branch: 2 branches
BranchTrueFalseTotal
if $attr 40 16 56
ref $attr ? : 40 0 40
141 16 return $self->SUPER::_attr_prop( $attr_name, $prop_name );
142 }
143 }
144
145 #-----------------------------------------------------------------
146
147 =head1 SUBROUTINES
148
149 =cut
150
151 #-----------------------------------------------------------------
152 # init
153 #-----------------------------------------------------------------
154 2 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
155 10 my ($self) = shift;
156 10 $self->SUPER::init();
157 10 $self->parent('OWL::Data::OWL::DatatypeProperty');
158 }
159 2 1;
160 __END__
« lib/OWL/Data/OWL/ObjectProperty.pm ↑ Summary lib/OWL/Data/Def/ObjectProperty.pm »