lib/MOBY/CrossReference.pm

filter: Statementstmt 100% 70 / 70 Branchbran 90.9% 20 / 22 Conditioncond 60.0% 9 / 15 MC/DCmcdc 33.3% 3 / 9 Subroutinesub 92.8% 13 / 14 Podpod 100% 9 / 9 totaltotal 89.2% 124 / 139 CC 17 SCAR 12.0
CC
17
Cov
93%
new
7.3
Object
3.5
type
3.0
CRAP 3.3
« blib/lib/MOBY/Client/Registration.pm ↑ Summary blib/lib/MOBY/Adaptor/moby/queryapi.pm »
1 package MOBY::CrossReference;
2  
3 #$Id: CrossReference.pm,v 1.3 2008/09/02 13:14:18 kawas Exp $
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use vars qw($AUTOLOAD @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 $VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/;
10  
11 =head1 NAME
12  
13 MOBY::Client::CrossReference - a small object describing a MOBY Simple input/output article
14  
15 =head1 SYNOPSIS
16  
17 use MOBY::CrossReference;
18 # do stuff with xref ... read below
19  
20  
21 =cut
22  
23 =head1 DESCRIPTION
24  
25 This holds all of the relevant information for a MOBY cross reference
26 of either the Xref type, or the Object type. Object cross-references
27 have only namespace and id attributes, while Xref cross-references
28 have namespace, id, authURI, serviceName, xref_type, and evidence_code
29 attributes. To determine which type of cross-reference you have
30 in-hand, call the "type" method.
31  
32 =head1 AUTHORS
33  
34 Mark Wilkinson (markw at illuminae dot com)
35  
36 =head1 METHODS
37  
38 =head2 new
39  
40 Usage : my $XR = MOBY::Client::CrossReference->new(%args)
41 Function : create SimpleArticle object
42 Returns : MOBY::Client::CrossReference object
43 Args : type => object || xref (required)
44 namespace => $ns (required)
45 id => $id (required)
46 authURI => $authURI
47 serviceName => $serviceName
48 evidence_code => $evidence_code
49 xref_type=> $xref_ontology_term
50 Object => The XML of a base MOBY Object in this ns/id
51  
52  
53 =head2 type
54  
55 Usage : $type = $XR->type($name)
56 Function : get/set type attribute
57 Returns : string; returns last value if new value set
58 Arguments : (required)one of "xref" or "object", depending on the
59 type of cross-ref you are making (new, or v0.5 API)
60  
61 =head2 namespace
62  
63 Usage : $ns = $XR->namespace($ns)
64 Function : get/set namespace
65 Returns : string; returns last value if new value set
66 Arguments : (optional) string representing namespace to set
67  
68 =head2 id
69  
70 Usage : $id = $XR->id($id)
71 Function : get/set id for the cross-reference
72 Returns : string; returns last value if new value set
73 Arguments : (optional) the id of the cross-reference
74  
75 =head2 authURI
76  
77 Usage : $auth = $XR->authURI($auth)
78 Function : get/set id for the authority for the xref
79 Returns : string; returns last value if new value set
80 Arguments : (optional) the new authority of the xref type reference
81  
82 =head2 serviceName
83  
84 Usage : $name = $XR->serviceName($name)
85 Function : get/set serviceName for the cross-reference
86 Returns : string; returns last value if new value set
87 Arguments : (optional) the new serviceName of the cross-reference
88  
89 =head2 evidence_code
90  
91 Usage : $code = $XR->evidence_code($code)
92 Function : get/set evidence_code for the cross-reference
93 Returns : string; returns last value if new value set
94 Arguments : (optional) the evidence_code of the cross-reference
95  
96 =head2 xref_type
97  
98 Usage : $xreftype = $XR->xref_type($xreftype)
99 Function : get/set xref_type for the cross-reference
100 Returns : string; returns last value if new value set
101 Arguments : (optional) the xref_type of the cross-reference
102  
103 =head2 Object
104  
105 Usage : $XML = $XR->Object()
106 Function : retrieve a base MOBY Object XML (e.g. to send to a service)
107 Returns : XML or empty string if there is no namespace or id value
108  
109 =cut
110  
111 {
112  
113 # Why do these methods return the PREVIOUS value of their respective variables?
114 # How would that be useful?
115 # Seems more intuitive to return new value, or perhaps even the object itself.
116 10 ▶ sub type {
Subroutine type: called CC=3 SCAR=11.0
Pod documented
117 # only two types are permitted.
118 10 my ( $self, $type ) = @_;
119 10 ▶ if ($type && ($type =~ /^(xref|object)$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type and $type =~ /^(xref|object)$/) 3 7 10
Condition100%3/3
$type and $type =~ /^(xref|object)$/
!ll&&!rl&&r
523
MC/DC100%2/2
$type and $type =~ /^(xref|object)$/
$type $type =~ /^(xref|object)$/
Truth table100%3/3
A and B
A= $typeB= $type =~ /^(xref|object)$/
ABresult
0X0
100
111
120 3 my $old = $self->{_type};
121 3 $self->{_type} = $type;
122 3 return $old;
123 }
124 7 return $self->{_type};
125 }
126  
127 7 ▶ sub namespace {
Subroutine namespace: called CC=2 SCAR=6.9
Pod documented
128 7 my ( $self, $type ) = @_;
129 7 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 2 5 7
130 2 my $old = $self->{_namespace};
131 2 $self->{_namespace} = $type;
132 2 return $old;
133 }
134 5 return $self->{_namespace};
135 }
136  
137 9 ▶ sub id {
Subroutine id: called CC=2 SCAR=6.9
Pod documented
138 9 my ( $self, $type ) = @_;
139 9 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 3 6 9
140 3 my $old = $self->{_id};
141 3 $self->{_id} = $type;
142 3 return $old;
143 }
144 6 return $self->{_id};
145 }
146  
147 2 ▶ sub authURI {
Subroutine authURI: called CC=2 SCAR=6.9
Pod documented
148 2 my ( $self, $type ) = @_;
149 2 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 1 1 2
150 1 my $old = $self->{_authURI};
151 1 $self->{_authURI} = $type;
152 1 return $old;
153 }
154 1 return $self->{_authURI};
155 }
156  
157 2 ▶ sub serviceName {
Subroutine serviceName: called CC=2 SCAR=6.9
Pod documented
158 2 my ( $self, $type ) = @_;
159 2 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 1 1 2
160 1 my $old = $self->{_serviceName};
161 1 $self->{_serviceName} = $type;
162 1 return $old;
163 }
164 1 return $self->{_serviceName};
165 }
166  
167 2 ▶ sub evidence_code {
Subroutine evidence_code: called CC=2 SCAR=6.9
Pod documented
168 2 my ( $self, $type ) = @_;
169 2 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 1 1 2
170 1 my $old = $self->{_evidenceCode};
171 1 $self->{_evidenceCode} = $type;
172 1 return $old;
173 }
174 1 return $self->{_evidenceCode};
175 }
176  
177 2 ▶ sub xref_type {
Subroutine xref_type: called CC=2 SCAR=6.9
Pod documented
178 2 my ( $self, $type ) = @_;
179 2 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 1 1 2
180 1 my $old = $self->{_xref_type};
181 1 $self->{_xref_type} = $type;
182 1 return $old;
183 }
184 1 return $self->{_xref_type};
185 }
186 }
187  
188 2 ▶sub new {
Subroutine new: called CC=7 SCAR=19.9
Pod documented
189 3 my ( $caller, %args ) = @_;
190 3 my $caller_is_obj = ref($caller);
191 3 ▶ return $caller if $caller_is_obj;
Branch: 1 branch
BranchTrueFalseTotal
if $caller_is_obj 0 3 3
192 3 ▶ my $class = $caller_is_obj || $caller;
Condition33%1/3
$caller_is_obj || $caller
l!l&&r!l&&!r
030
MC/DC0%0/2
$caller_is_obj || $caller
$caller_is_obj $caller
Truth table33%1/3
A || B
A= $caller_is_objB= $caller
ABresult
1X1
011
000
193 3 my $proxy;
194 3 my $self = bless {}, $class;
195 3 ▶ while ( my ( $key, $value ) = each %args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 6 3 9
196 6 $self->$key($value);
197 }
198 3 ▶ return undef unless ( $self->type && $self->namespace && $self->id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->type and $self->namespace and $self->id 1 2 3
Condition66%4/6
$self->type and $self->namespace and $self->id
!ll&&!rl&&r
102
$self->type and $self->namespace
!ll&&!rl&&r
102
MC/DC33%1/3
$self->type and $self->namespace and $self->id
$self->type $self->namespace $self->id
Truth table50%2/4
A and B and C
A= $self->typeB= $self->namespaceC= $self->id
ABCresult
0XX0
10X0
1100
1111
199 2 return $self;
200 }
201  
202 1 ▶sub Object {
Subroutine Object: called CC=3 SCAR=12.5
Pod documented
203 1 my ($self) = @_;
204 1 ▶ return "" unless ( $self->namespace && $self->id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->namespace and $self->id 0 1 1
Condition33%1/3
$self->namespace and $self->id
!ll&&!rl&&r
001
MC/DC0%0/2
$self->namespace and $self->id
$self->namespace $self->id
Truth table33%1/3
A and B
A= $self->namespaceB= $self->id
ABresult
0X0
100
111
205 1 return "<moby:Object moby:namespace='"
206 . ( $self->namespace )
207 . "' moby:id='"
208 . ( $self->id ) . "'/>";
209 }
210 0 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
211 2 1;
« blib/lib/MOBY/Client/Registration.pm ↑ Summary blib/lib/MOBY/Adaptor/moby/queryapi.pm »