Pluggable/Folder.pm

filter: Statementstmt 85.5% 59 / 69 Branchbran 75.0% 12 / 16 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 88.2% 15 / 17 Podpod 100% 8 / 8 totaltotal 76.5% 98 / 128 CC 14 SCAR 19.7
CC
14
Cov
77%
node
16.6
data
4.0
NetworkLink
2.0
CRAP 7.2
« Pluggable/Plugin/Style.pm ↑ Summary Pluggable/Contrib/MultiPolygon.pm »
1 package Geo::GoogleEarth::Pluggable::Folder;
2 7 ▶use base qw{Geo::GoogleEarth::Pluggable::Base};
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use XML::LibXML::LazyBuilder qw{E};
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use Scalar::Util qw{blessed};
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use Module::Pluggable search_path => "Geo::GoogleEarth::Pluggable::Plugin";
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use base qw{Method::Autoload};
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 7 ▶use Geo::GoogleEarth::Pluggable::NetworkLink;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Geo::GoogleEarth::Pluggable::LookAt;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 7 our $VERSION='0.17';
15  
16 =head1 NAME
17  
18 Geo::GoogleEarth::Pluggable::Folder - Geo::GoogleEarth::Pluggable::Folder object
19  
20 =head1 SYNOPSIS
21  
22 use Geo::GoogleEarth::Pluggable;
23 my $document=Geo::GoogleEarth::Pluggable->new;
24 my $folder=$document->Folder(name=>"My Folder");
25  
26 =head1 DESCRIPTION
27  
28 Geo::GoogleEarth::Pluggable::Folder is a L<Geo::GoogleEarth::Pluggable::Base> with a few other methods.
29  
30 =head1 USAGE
31  
32 my $folder=$document->Folder(); #add folder to $document
33 my $subfolder=$folder->Folder(); #add folder to $folder
34  
35 =head1 METHODS
36  
37 =cut
38  
39 =head2 initialize
40  
41 We overide the default "initialize" method in order to append the "plugins" method from L<Module::Pluggable> on to the packages list of the L<Method::Autoload> package.
42  
43 The "packages" property is what is needed by L<Method::Autoload> package. The "plugins" method is what is provided by L<Module::Pluggable>. So, the Folder package now has available to it every method in the "Plugins" folder at runtime.
44  
45 =cut
46  
47 8 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
Pod documented
48 8 my $self = shift();
49 8 %$self=@_;
50 8 $self->pushPackages($self->plugins);
51 }
52  
53 =head2 Folder
54  
55 Constructs a new Folder object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction.
56  
57 my $folder=$folder->Folder(name=>"My Folder");
58 $folder->Folder(name=>"My Folder");
59  
60 =cut
61  
62 1 ▶sub Folder {
Subroutine Folder: called CC=1 SCAR=0.0
Pod documented
63 1 my $self=shift;
64 1 my $obj=Geo::GoogleEarth::Pluggable::Folder->new(document=>$self->document, @_);
65 1 $self->data($obj);
66 1 return $obj;
67 }
68  
69 =head2 NetworkLink
70  
71 Constructs a new NetworkLink object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction.
72  
73 $folder->NetworkLink(name=>"My NetworkLink", url=>"./anotherdoc.kml");
74  
75 =cut
76  
77 0 ▶sub NetworkLink {
Subroutine NetworkLink: not called CC=1 SCAR=6.9
Pod documented
78 0 my $self=shift();
79 0 my $obj=Geo::GoogleEarth::Pluggable::NetworkLink->new(document=>$self->document, @_);
80 0 $self->data($obj);
81 0 return $obj;
82 }
83  
84 =head2 LookAt
85  
86 Constructs a new LookAt object and returns the object reference to assign to other object "lookat" properties.
87  
88 $document->LookAt(
89 latitude => $lat, #decimal degrees
90 longitude => $lon, #decimal degrees
91 range => $range, #meters
92 tilt => $tilt, #decimal degrees from veritical
93 heading => $header, #decimal degrees from North
94 );
95  
96 =cut
97  
98 0 ▶sub LookAt {
Subroutine LookAt: not called CC=1 SCAR=6.9
Pod documented
99 0 my $self=shift();
100 0 my $obj=Geo::GoogleEarth::Pluggable::LookAt->new(document=>$self->document, @_);
101 0 $self->data($obj);
102 0 return $obj;
103 }
104  
105 =head2 type
106  
107 Returns the object type.
108  
109 my $type=$folder->type;
110  
111 =cut
112  
113 3 ▶sub type {"Folder"};
Subroutine type: called CC=1 SCAR=0.0
Pod documented
114  
115 =head2 node
116  
117 =cut
118  
119 8 ▶sub node {
Subroutine node: called CC=11 SCAR=28.1
Pod documented
120 8 my $self=shift;
121 8 my @data=();
122 8 ▶ push @data, E(name=>{}, $self->name) if defined $self->name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->name 1 7 8
123 8 push @data, E(Snippet=>{maxLines=>scalar(@{$self->Snippet})}, join("\n", @{$self->Snippet}));
124 8 ▶ push @data, E(description=>{}, $self->description)
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->description 0 8 8
125 if defined $self->description;
126 8 ▶ push @data, E(open=>{}, $self->open) if defined $self->open;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->open 0 8 8
127 8 my @style=();
128 8 my @stylemap=();
129 8 my @element=();
130 8 foreach my $obj ($self->data) {
131 6 ▶ if (blessed($obj) and $obj->can("type") and $obj->type eq "Style") {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($obj) and $obj->can('type') and $obj->type eq 'Style') { } 0 6 6
elsif (builtin::blessed($obj) and $obj->can('type') and $obj->type eq 'StyleMap') { } 0 6 6
Condition33%2/6
builtin::blessed($obj) and $obj->can("type") and $obj->type eq "Style"
!ll&&!rl&&r
060
builtin::blessed($obj) and $obj->can("type")
!ll&&!rl&&r
006
MC/DC0%0/3
builtin::blessed($obj) and $obj->can("type") and $obj->type eq "Style"
builtin::blessed($obj) $obj->can("type") $obj->type eq "Style"
Truth table25%1/4
A and B and C
A= builtin::blessed($obj)B= $obj->can("type")C= $obj->type eq "Style"
ABCresult
0XX0
10X0
1100
1111
132 0 push @style, $obj->node;
133 ▶ } elsif (blessed($obj) and $obj->can("type") and $obj->type eq "StyleMap") {
Condition33%2/6
builtin::blessed($obj) and $obj->can("type") and $obj->type eq "StyleMap"
!ll&&!rl&&r
060
builtin::blessed($obj) and $obj->can("type")
!ll&&!rl&&r
006
MC/DC0%0/3
builtin::blessed($obj) and $obj->can("type") and $obj->type eq "StyleMap"
builtin::blessed($obj) $obj->can("type") $obj->type eq "StyleMap"
Truth table25%1/4
A and B and C
A= builtin::blessed($obj)B= $obj->can("type")C= $obj->type eq "StyleMap"
ABCresult
0XX0
10X0
1100
1111
134 0 push @stylemap, $obj->node;
135 } else {
136 6 push @element, $obj->node;
137 }
138 }
139 8 return E($self->type=>{}, @data, @style, @stylemap, @element);
140 }
141  
142 =head2 data
143  
144 Pushes arguments onto data array and returns an array or reference that holds folder object content. This is a list of objects that supports a type and structure method.
145  
146 my $data=$folder->data;
147 my @data=$folder->data;
148 $folder->data($placemark);
149  
150 =cut
151  
152 13 ▶sub data {
Subroutine data: called CC=4 SCAR=13.9
Pod documented
153 13 my $self=shift();
154 13 ▶ $self->{'data'} = [] unless ref($self->{'data'}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"data"} eq "ARRAY" 7 6 13
155 13 my $data=$self->{'data'};
156 13 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 5 8 13
157 5 push @$data, @_;
158 }
159 13 ▶ return wantarray ? @$data : $data;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 8 5 13
160 }
161  
162 =head2 open
163  
164 =cut
165  
166 8 ▶sub open {shift->{"open"}};
Subroutine open: called CC=1 SCAR=0.0
Pod documented
167  
168 =head1 BUGS
169  
170 Please log on RT and send to the geo-perl email list.
171  
172 =head1 LIMITATIONS
173  
174 Due to limitations in Perl hashes, it is not possible to specify the order of certain elements and attributes in the XML.
175  
176 =head1 TODO
177  
178 =head1 SUPPORT
179  
180 Try geo-perl email list.
181  
182 =head1 AUTHOR
183  
184 Michael R. Davis (mrdvt92)
185 CPAN ID: MRDVT
186  
187 =head1 COPYRIGHT
188  
189 This program is free software licensed under the...
190  
191 The BSD License
192  
193 The full text of the license can be found in the
194 LICENSE file included with this module.
195  
196 =head1 SEE ALSO
197  
198 L<Geo::GoogleEarth::Pluggable>, L<Module::Pluggable> L<Method::Autoload>, L<XML::LibXML::LazyBuilder>
199  
200 =cut
201  
202 7 1;
« Pluggable/Plugin/Style.pm ↑ Summary Pluggable/Contrib/MultiPolygon.pm »