blib/lib/W3C/SOAP/XSD/Document/SimpleType.pm

filter: Statementstmt 78.2% 54 / 69 Branchbran 33.3% 4 / 12 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 68.4% 13 / 19 Podpod 100% 3 / 3 totaltotal 67.2% 76 / 113 CC 10 SCAR 12.4
CC
10
Cov
69%
moose_base_type
10.1
moosex_type
6.0
_type
2.3
CRAP 3.5
« blib/lib/W3C/SOAP/Client.pm ↑ Summary blib/lib/W3C/SOAP/Parser.pm »
1 package W3C::SOAP::XSD::Document::SimpleType;
2  
3 # Created on: 2012-05-26 19:04:19
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use List::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 #use List::MoreUtils;
15 7 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 7 ▶use W3C::SOAP::Utils qw/split_ns/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 7 extends 'W3C::SOAP::XSD::Document::Type';
20  
21 7 our $VERSION = 0.13;
22  
23 7 has type => (
24 is => 'rw',
25 isa => 'Str',
26 builder => '_type',
27 lazy => 1,
28 );
29 7 has list => (
30 is => 'rw',
31 isa => 'Bool',
32 builder => '_list',
33 lazy => 1,
34 );
35 7 has enumeration => (
36 is => 'rw',
37 isa => 'ArrayRef[Str]',
38 builder => '_enumeration',
39 lazy => 1,
40 );
41 7 has pattern => (
42 is => 'rw',
43 isa => 'Maybe[Str]',
44 builder => '_pattern',
45 predicate => 'has_pattern',
46 lazy => 1,
47 );
48 7 has maxLength => (
49 is => 'rw',
50 isa => 'Maybe[Int]',
51 builder => '_maxLength',
52 predicate => 'has_minLength',
53 lazy => 1,
54 );
55 7 has minLength => (
56 is => 'rw',
57 isa => 'Maybe[Int]',
58 builder => '_minLength',
59 predicate => 'has_maxLength',
60 lazy => 1,
61 );
62 7 has length => (
63 is => 'rw',
64 isa => 'Maybe[Int]',
65 builder => '_length',
66 predicate => 'has_length',
67 lazy => 1,
68 );
69  
70 sub _type {
71 24 ▶ my ($self) = @_;
Subroutine _type: called CC=2 SCAR=8.4
72 24 my ($restriction) = $self->document->xpc->findnodes('xsd:restriction', $self->node);
73  
74 24 ▶ return $restriction->getAttribute('base') if $restriction;
Branch: 1 branch
BranchTrueFalseTotal
if $restriction 24 0 24
75  
76 0 ($restriction) = $self->document->xpc->findnodes('xsd:list/xsd:simpleType/xsd:restriction', $self->node);
77  
78 0 return $restriction->getAttribute('base');
79 }
80  
81 sub _list {
82 6 ▶ my ($self) = @_;
Subroutine _list: called CC=2 SCAR=7.1
83 6 my ($restriction) = $self->document->xpc->findnodes('xsd:list', $self->node);
84  
85 6 ▶ return $restriction ? 1 : undef;
Branch: 1 branch
BranchTrueFalseTotal
$restriction ? : 0 6 6
86 }
87  
88 sub _enumeration {
89 29 ▶ my ($self) = @_;
Subroutine _enumeration: called CC=2 SCAR=6.9
90 29 my @nodes = $self->document->xpc->findnodes('xsd:restriction/xsd:enumeration', $self->node);
91 29 my @enumeration;
92  
93 29 for my $node (@nodes) {
94 69 push @enumeration, $node->getAttribute('value');
95 }
96  
97 29 return \@enumeration;
98 }
99  
100 0 ▶sub _pattern { return shift->_build_restriction('pattern') }
Subroutine _pattern: not called CC=1 SCAR=6.9
101 0 ▶sub _maxLength { return shift->_build_restriction('maxLength') }
Subroutine _maxLength: not called CC=1 SCAR=6.9
102 0 ▶sub _minLength { return shift->_build_restriction('minLength') }
Subroutine _minLength: not called CC=1 SCAR=6.9
103 0 ▶sub _length { return shift->_build_restriction('length') }
Subroutine _length: not called CC=1 SCAR=6.9
104 sub _build_restriction {
105 0 ▶ my ($self, $type) = @_;
Subroutine _build_restriction: not called CC=1 SCAR=6.9
106 0 my ($node) = $self->document->xpc->findnodes("xsd:restriction/xsd:$type", $self->node);
107 0 return $node->getAttribute('value');
108 }
109  
110 sub moose_type {
111 209 ▶ my ($self) = @_;
Subroutine moose_type: called CC=2 SCAR=7.0
Pod documented
112  
113 209 ▶ warn "No name for ".$self->node->toString if !$self->name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->name 0 209 209
114 209 my $type = $self->document->module . ':' . $self->name;
115  
116 209 return $type;
117 }
118  
119 sub moose_base_type {
120 14 ▶ my ($self) = @_;
Subroutine moose_base_type: called CC=5 SCAR=23.1
Pod documented
121 14 my ($ns, $type) = split_ns($self->type);
122 14 ▶ $ns ||= $self->document->target_namespace;
Condition33%1/3
$ns ||= $self->document->target_namespace
l!l&&r!l&&!r
1400
MC/DC0%0/2
$ns ||= $self->document->target_namespace
$ns $self->document->target_namespace
Truth table33%1/3
A ||= B
A= $nsB= $self->document->target_namespace
ABresult
1X1
011
000
123 14 ▶ return "xs:$type" if $self->document->ns_map->{$ns} && $self->document->ns_map->{$ns} eq 'http://www.w3.org/2001/XMLSchema';
Branch: 1 branch
BranchTrueFalseTotal
if $self->document->ns_map->{$ns} and $self->document->ns_map->{$ns} eq "http://www.w3.org/2001/XMLSchema" 14 0 14
Condition33%1/3
$self->document->ns_map->{$ns} and $self->document->ns_map->{$ns} eq "http://www.w3.org/2001/XMLSchema"
!ll&&!rl&&r
0014
MC/DC0%0/2
$self->document->ns_map->{$ns} and $self->document->ns_map->{$ns} eq "http://www.w3.org/2001/XMLSchema"
$self->document->ns_map->{$ns} $self->document->ns_map->{$ns} eq "http://www.w3.org/2001/XMLSchema"
Truth table33%1/3
A and B
A= $self->document->ns_map->{$ns}B= $self->document->ns_map->{$ns} eq "http://www.w3.org/2001/XMLSchema"
ABresult
0X0
100
111
124  
125 0 my $ns_uri = $self->document->get_ns_uri($ns, $self->node);
126  
127 0 ▶ return "xs:$type" if $ns_uri eq 'http://www.w3.org/2001/XMLSchema';
Branch: 1 branch
BranchTrueFalseTotal
if $ns_uri eq "http://www.w3.org/2001/XMLSchema" 0 0 0
128  
129 0 return $type;
130 }
131  
132 sub moosex_type {
133 0 ▶ my ($self) = @_;
Subroutine moosex_type: not called CC=2 SCAR=17.9
Pod documented
134  
135 0 ▶ warn "No name for ".$self->node->toString if !$self->name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->name 0 0 0
136 0 return $self->name;
137 }
138  
139 7 1;
140  
141 __END__
142  
143 =head1 NAME
144  
145 W3C::SOAP::XSD::Document::SimpleType - Represents simpleType elements of XSD documents
146  
147 =head1 VERSION
148  
149 This documentation refers to W3C::SOAP::XSD::Document::SimpleType version 0.13.
150  
151  
152 =head1 SYNOPSIS
153  
154 use W3C::SOAP::XSD::Document::SimpleType;
155  
156 # Brief but working code example(s) here showing the most common usage(s)
157 # This section will be as far as many users bother reading, so make it as
158 # educational and exemplary as possible.
159  
160  
161 =head1 DESCRIPTION
162  
163  
164 =head1 SUBROUTINES/METHODS
165  
166 =over 4
167  
168 =item C<moose_type ()>
169  
170 =item C<moose_base_type ()>
171  
172 =item C<moosex_type ()>
173  
174 =back
175  
176 =head1 DIAGNOSTICS
177  
178 =head1 CONFIGURATION AND ENVIRONMENT
179  
180 =head1 DEPENDENCIES
181  
182 =head1 INCOMPATIBILITIES
183  
184 =head1 BUGS AND LIMITATIONS
185  
186 There are no known bugs in this module.
187  
188 Please report problems to Ivan Wills (ivan.wills@gmail.com).
189  
190 Patches are welcome.
191  
192 =head1 AUTHOR
193  
194 Ivan Wills - (ivan.wills@gmail.com)
195  
196 =head1 LICENSE AND COPYRIGHT
197  
198 Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
199 All rights reserved.
200  
201 This module is free software; you can redistribute it and/or modify it under
202 the same terms as Perl itself. See L<perlartistic>. This program is
203 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
204 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
205 PARTICULAR PURPOSE.
206  
207 =cut
« blib/lib/W3C/SOAP/Client.pm ↑ Summary blib/lib/W3C/SOAP/Parser.pm »