| 1 | # Copyright 2012, Google Inc. All Rights Reserved. | ||||||||||
| 2 | # | ||||||||||
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| 4 | # you may not use this file except in compliance with the License. | ||||||||||
| 5 | # You may obtain a copy of the License at | ||||||||||
| 6 | # | ||||||||||
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| 8 | # | ||||||||||
| 9 | # Unless required by applicable law or agreed to in writing, software | ||||||||||
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| 12 | # See the License for the specific language governing permissions and | ||||||||||
| 13 | # limitations under the License. | ||||||||||
| 14 | # | ||||||||||
| 15 | # Custom class generator based on SOAP::WSDL::Generator::Template::XSD, with | ||||||||||
| 16 | # some overriden methods via inheritance. | ||||||||||
| 17 | |||||||||||
| 18 | package Google::Ads::SOAP::Generator::Generator; | ||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | ▶ | use base qw(SOAP::WSDL::Generator::Template::XSD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | use Google::Ads::SOAP::Generator::TypemapVisitor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | use Class::Std::Fast::Storable; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | ▶ | use Cwd 'abs_path'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 1 | ▶ | use File::Basename; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 32 | 0 | my ($self, $ident, $arg_ref) = @_; | |||||||||
| 33 | |||||||||||
| 34 | 0 | $self->set_INCLUDE_PATH( | |||||||||
| 35 | $self->_get_local_include_path() . q{:} . $self->get_INCLUDE_PATH()); | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub _get_local_include_path { | ||||||||
|
Subroutine
_get_local_include_path: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | |||||||||||
| 40 | 0 | my $template_path = | |||||||||
| 41 | File::Spec->catdir(File::Spec->rel2abs(dirname(__FILE__)), "Template"); | ||||||||||
| 42 | 0 | return abs_path($template_path); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub generate_filename { | ||||||||
|
Subroutine
generate_filename: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 46 | 0 | my ($self, $name) = @_; | |||||||||
| 47 | |||||||||||
| 48 | 0 | $name =~ s{ \. }{::}xmsg; | |||||||||
| 49 | 0 | $name =~ s{ \- }{_}xmsg; | |||||||||
| 50 | 0 | $name =~ s{ :: }{/}xmsg; | |||||||||
| 51 | 0 | return "$name.pm"; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub visit_XSD_ComplexType { | ||||||||
|
Subroutine
visit_XSD_ComplexType: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 55 | 0 | my ($self, $type) = @_; | |||||||||
| 56 | |||||||||||
| 57 | my $output = | ||||||||||
| 58 | defined $SOAP::WSDL::Generator::Template::XSD::output_of{ident $self} | ||||||||||
| 59 | 0 | ▶ | ? $SOAP::WSDL::Generator::Template::XSD::output_of{ident $self} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | : $self->generate_filename( | ||||||||||
| 61 | $self->get_name_resolver()->create_xsd_name($type)); | ||||||||||
| 62 | 0 | ▶ | warn "Creating complexType class $output \n" if not $self->get_silent(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $self->_process('complexType.tt', {complexType => $type, NO_POD => 1}, | |||||||||
| 64 | $output); | ||||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub generate_typemap { | ||||||||
|
Subroutine
generate_typemap: not called CC=5 SCAR=30.1
Pod
documented
| |||||||||||
| 68 | 0 | my ($self, $arg_ref) = @_; | |||||||||
| 69 | 0 | my $visitor = Google::Ads::SOAP::Generator::TypemapVisitor->new({ | |||||||||
| 70 | type_prefix => $self->get_type_prefix(), | ||||||||||
| 71 | element_prefix => $self->get_element_prefix(), | ||||||||||
| 72 | definitions => $self->get_definitions(), | ||||||||||
| 73 | typemap => { | ||||||||||
| 74 | 'Fault' => 'SOAP::WSDL::SOAP::Typelib::Fault11', | ||||||||||
| 75 | 'Fault/faultcode' => 'SOAP::WSDL::XSD::Typelib::Builtin::anyURI', | ||||||||||
| 76 | 'Fault/faultactor' => 'SOAP::WSDL::XSD::Typelib::Builtin::token', | ||||||||||
| 77 | 'Fault/faultstring' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', | ||||||||||
| 78 | # PATCH Map our own FaultDetail object. | ||||||||||
| 79 | 'Fault/detail' => 'Google::Ads::AdWords::FaultDetail', | ||||||||||
| 80 | # END OF PATCH. | ||||||||||
| 81 | }, | ||||||||||
| 82 | resolver => $self->get_name_resolver(), | ||||||||||
| 83 | }); | ||||||||||
| 84 | |||||||||||
| 85 | 1 | ▶ | use SOAP::WSDL::Generator::Iterator::WSDL11; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 86 | 0 | my $iterator = SOAP::WSDL::Generator::Iterator::WSDL11->new( | |||||||||
| 87 | {definitions => $self->get_definitions}); | ||||||||||
| 88 | |||||||||||
| 89 | 0 | for my $service (@{$self->get_definitions->get_service}) { | |||||||||
| 90 | 0 | $iterator->init({node => $service}); | |||||||||
| 91 | 0 | ▶ | while (my $node = $iterator->get_next()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | $node->_accept($visitor); | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | my $output = | ||||||||||
| 96 | $arg_ref->{output} | ||||||||||
| 97 | ? $arg_ref->{output} | ||||||||||
| 98 | 0 | ▶ | : $self->generate_filename( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | $self->get_name_resolver()->create_typemap_name($service)); | ||||||||||
| 100 | 0 | ▶ | print "Creating typemap class $output\n" if not $self->get_silent(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | 0 | $self->_process( | |||||||||
| 102 | 'Typemap.tt', | ||||||||||
| 103 | { | ||||||||||
| 104 | service => $service, | ||||||||||
| 105 | typemap => $visitor->get_typemap(), | ||||||||||
| 106 | NO_POD => 1, | ||||||||||
| 107 | }, | ||||||||||
| 108 | $output | ||||||||||
| 109 | ); | ||||||||||
| 110 | } | ||||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | 1 | return 1; | |||||||||