London.pm

filter: Statementstmt 92.0% 23 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod n/a totaltotal 88.5% 31 / 35 CC 1 SCAR 1.8
CC
1
Cov
92%
_build_json
2.0
_build_skip
2.0
BEGIN
1.0
CRAP 1.2
↑ Summary London/Line/Bakerloo.pm »
1 package Map::Tube::London;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 our $VERSION = qv('v2.0.1');
8 our $AUTHORITY = 'cpan:MANWAR';
9  
10 =head1 NAME
11  
12 Map::Tube::London - Interface to the London Tube Map.
13  
14 =head1 VERSION
15  
16 Version v2.0.1
17  
18 =cut
19  
20 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use File::ShareDir ':ALL';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 has json => (is => 'lazy');
28 has skip => (is => 'lazy');
29 with 'Map::Tube';
30  
31 0 ▶sub _build_json { dist_file('Map-Tube-London', 'london-map.json') }
Subroutine _build_json: not called CC=1 SCAR=6.9
32 sub _build_skip {
33 return {
34 0 ▶ 'Jubilee' => {
Subroutine _build_skip: not called CC=1 SCAR=6.9
35 'Baker Street' => { 'Finchley Road' => 1 },
36 'Finchley Road' => { 'Wembley Park' => 1 },
37 },
38 'Bakerloo' => {
39 'Edgware Road' => { 'Baker Street' => 1 },
40 'Finchley Road' => { 'Baker Street' => 1 },
41 },
42 'Circle' => {
43 'Wood Lane' => { 'White City' => 1 },
44 },
45 'District' => {
46 "Earl's Court" => { 'Barons Court' => 1 },
47 'Hammersmith' => { 'Turnham Green' => 1 },
48 'Acton Town' => { 'Turnham Green' => 1 },
49 },
50 'Northern' => {
51 'Waterloo' => { 'Bank' => 1 },
52 },
53 'DLR' => {
54 'West Ham' => { 'Stratford' => 1 },
55 },
56 };
57 }
58  
59 =head1 DESCRIPTION
60  
61 It currently provides functionality to find the shortest route between the two
62 given nodes. It covers the following tube lines:
63  
64 =over 2
65  
66 =item * L<Bakerloo Line|Map::Tube::London::Line::Bakerloo>
67  
68 =item * L<Central Line|Map::Tube::London::Line::Central>
69  
70 =item * L<Circle Line|Map::Tube::London::Line::Circle>
71  
72 =item * L<District Line|Map::Tube::London::Line::District>
73  
74 =item * L<Dockland Light Railway Line|Map::Tube::London::Line::DLR>
75  
76 =item * L<Hammersmith & City Line|Map::Tube::London::Line::HammersmithCity>
77  
78 =item * L<Jubilee Line|Map::Tube::London::Line::Jubilee>
79  
80 =item * L<Metropolitan Line|Map::Tube::London::Line::Metropolitan>
81  
82 =item * L<Northern Line|Map::Tube::London::Line::Northern>
83  
84 =item * L<London Overground Line|Map::Tube::London::Line::Overground>
85  
86 =item * L<Piccadilly Line|Map::Tube::London::Line::Piccadilly>
87  
88 =item * L<Victoria Line|Map::Tube::London::Line::Victoria>
89  
90 =item * L<Waterloo & City Line|Map::Tube::London::Line::WaterlooCity>
91  
92 =back
93  
94 =head1 CONSTRUCTOR
95  
96 The constructor DO NOT expects parameters.This setup the default node definitions.
97  
98 use strict; use warnings;
99 use Map::Tube::London;
100  
101 my $tube = Map::Tube::London->new;
102  
103 =head1 METHODS
104  
105 =head2 get_shortest_route($from, $to)
106  
107 It expects C<$from> and C<$to> station name, required param. It returns an object
108 of type L<Map::Tube::Route>. On error it throws exception of type L<Map::Tube::Exception>.
109  
110 use strict; use warnings;
111 use Map::Tube::London;
112  
113 my $tube = Map::Tube::London->new;
114 my $route = $tube->get_shortest_route('Baker Street', 'Farringdon');
115  
116 print "Route: $route\n";;
117  
118 =head2 as_image($line_name)
119  
120 It expects the plugin L<Map::Tube::Plugin::Graph> to be installed. Returns line
121 image as base64 encoded string if C<$line_name> passed in otherwise it returns
122 base64 encoded string of the entire map.
123  
124 use strict; use warnings;
125 use MIME::Base64;
126 use Map::Tube::London;
127  
128 my $tube = Map::Tube::London->new;
129 my $map = $tube->name;
130 open(my $IMAGE, ">", "$map.png");
131 or die "ERROR: Can't open [$map.png]: $!";
132 binmode($IMAGE);
133 print $IMAGE decode_base64($tube->as_image);
134 close($IMAGE);
135  
136 The L<London Tube Map|https://raw.githubusercontent.com/manwar/Map-Tube-London/master/maps/London-Tube.png>
137 as generated by plugin L<Map::Tube::Plugin::Graph>.
138  
139 =begin html
140  
141 <a href = "https://raw.githubusercontent.com/manwar/Map-Tube-London/master/maps/London-Tube.png">
142 <img src = "https://raw.githubusercontent.com/manwar/Map-Tube-London/master/maps/London-Tube.png"
143 alt = "London Tube Map"
144 width = "740px"
145 height = "780px"/>
146 </a>
147  
148 =end html
149  
150 =head1 AUTHOR
151  
152 Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >>
153  
154 =head1 REPOSITORY
155  
156 L<https://github.com/manwar/Map-Tube-London>
157  
158 =head1 CONTRIBUTORS
159  
160 =over 2
161  
162 =item * Ed J
163  
164 =back
165  
166 =head1 BUGS
167  
168 Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/Map-Tube-London/issues>.
169 I will be notified and then you'll automatically be notified of progress on your
170 bug as I make changes.
171  
172 =head1 SUPPORT
173  
174 You can find documentation for this module with the perldoc command.
175  
176 perldoc Map::Tube::London
177  
178 You can also look for information at:
179  
180 =over 4
181  
182 =item * BUG Report
183  
184 L<https://github.com/manwar/Map-Tube-London/issues>
185  
186 =item * AnnoCPAN: Annotated CPAN documentation
187  
188 L<http://annocpan.org/dist/Map-Tube-London>
189  
190 =item * CPAN Ratings
191  
192 L<http://cpanratings.perl.org/d/Map-Tube-London>
193  
194 =item * Search MetaCPAN
195  
196 L<https://metacpan.org/dist/Map-Tube-London>
197  
198 =back
199  
200 =head1 LICENSE AND COPYRIGHT
201  
202 Copyright (C) 2014 - 2024 Mohammad Sajid Anwar.
203  
204 This program is free software; you can redistribute it and / or modify it under
205 the terms of the the Artistic License (2.0). You may obtain a copy of the full
206 license at:
207  
208 L<http://www.perlfoundation.org/artistic_license_2_0>
209  
210 Any use, modification, and distribution of the Standard or Modified Versions is
211 governed by this Artistic License.By using, modifying or distributing the Package,
212 you accept this license. Do not use, modify, or distribute the Package, if you do
213 not accept this license.
214  
215 If your Modified Version has been derived from a Modified Version made by someone
216 other than you,you are nevertheless required to ensure that your Modified Version
217 complies with the requirements of this license.
218  
219 This license does not grant you the right to use any trademark, service mark,
220 tradename, or logo of the Copyright Holder.
221  
222 This license includes the non-exclusive, worldwide, free-of-charge patent license
223 to make, have made, use, offer to sell, sell, import and otherwise transfer the
224 Package with respect to any patent claims licensable by the Copyright Holder that
225 are necessarily infringed by the Package. If you institute patent litigation
226 (including a cross-claim or counterclaim) against any party alleging that the
227 Package constitutes direct or contributory patent infringement,then this Artistic
228 License to you shall terminate on the date that such litigation is filed.
229  
230 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
231 CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
232 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
233 NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
234 REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
235 INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
236 OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
237  
238 =cut
239  
240 1; # End of Map::Tube::London
↑ Summary London/Line/Bakerloo.pm »