File Coverage

blib/lib/Map/Tube/London.pm
Criterion Covered Total %
statement 14 15 93.3
branch n/a
condition n/a
subroutine 5 6 83.3
pod n/a
total 19 21 90.4


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