Tokyo.pm

filter: Statementstmt 93.3% 14 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 90.4% 19 / 21 CC 1 SCAR 1.5
CC
1
Cov
93%
_build_xml
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary Tokyo/Line/Asakusa.pm »
1 package Map::Tube::Tokyo;
2  
3 $Map::Tube::Tokyo::VERSION = '0.49';
4 $Map::Tube::Tokyo::AUTHORITY = 'cpan:MANWAR';
5  
6 =encoding utf8
7  
8 =head1 NAME
9  
10 Map::Tube::Tokyo - Interface to the Tokyo Subway Map.
11  
12 =head1 VERSION
13  
14 Version 0.49
15  
16 =cut
17  
18 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use File::ShareDir ':ALL';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 has xml => (is => 'lazy');
26 with 'Map::Tube';
27  
28 0 ▶sub _build_xml { dist_file('Map-Tube-Tokyo', 'tokyo-map.xml') }
Subroutine _build_xml: not called CC=1 SCAR=6.9
29  
30 =head1 DESCRIPTION
31  
32 It currently provides functionality to find the shortest route between the two
33 given stations. It covers the following Tokyo Subway Lines just yet:
34  
35 =over 2
36  
37 =item * L<Asakusa Line|Map::Tube::Tokyo::Line::Asakusa>
38  
39 =item * L<Chiyoda Line|Map::Tube::Tokyo::Line::Chiyoda>
40  
41 =back
42  
43 =head1 TODO (Subway Lines)
44  
45 =over 2
46  
47 =item * Mita Line
48  
49 =item * Shinjuku Line
50  
51 =item * Hibiya Line
52  
53 =item * Tōzai Line
54  
55 =item * Yūrakuchō Line
56  
57 =item * Hanzōmon Line
58  
59 =item * Namboku Line
60  
61 =item * Fukutoshin Line
62  
63 =item * Marunouchi Line
64  
65 =item * Ginza Line
66  
67 =item * Oedo Line
68  
69 =back
70  
71 For more information about Tokyo Map, click L<here|http://en.wikipedia.org/wiki/Tokyo_subway>.
72  
73 =head1 CONSTRUCTOR
74  
75 The constructor DO NOT expects parameters.This setup the default node definitions.
76  
77 use strict; use warnings;
78 use Map::Tube::Tokyo;
79  
80 my $subway = Map::Tube::Tokyo->new;
81  
82 =head1 METHODS
83  
84 =head2 get_shortest_route($from, $to)
85  
86 It expects C<$from> and C<$to> station name, required param. It returns an object
87 of type L<Map::Tube::Route>. On error it throws exception of type L<Map::Tube::Exception>.
88  
89 use strict; use warnings;
90 use Map::Tube::Tokyo;
91  
92 my $subway = Map::Tube::Tokyo->new;
93 my $route = $subway->get_shortest_route('Takaracho', 'Otemachi');
94  
95 print "Route: $route\n";;
96  
97 =head2 as_image($line_name)
98  
99 It expects the plugin L<Map::Tube::Plugin::Graph> to be installed. Returns line
100 image as base64 encoded string if C<$line_name> passed in otherwise it returns
101 base64 encoded string of the entire map.
102  
103 use strict; use warnings;
104 use MIME::Base64;
105 use Map::Tube::Tokyo;
106  
107 my $subway = Map::Tube::Tokyo->new;
108 my $map = $subway->name;
109 open(my $IMAGE, ">", "$map.png")
110 or die "ERROR: Can't open [$map.png]: $!";
111 binmode($IMAGE);
112 print $IMAGE decode_base64($subway->as_image);
113 close($IMAGE);
114  
115 The L<Tokyo Subway Map|https://raw.githubusercontent.com/manwar/Map-Tube-Tokyo/master/maps/Tokyo-Subway.png>
116 map as generated by plugin L<Map::Tube::Plugin::Graph>.
117  
118 =begin html
119  
120 <a href = "https://raw.githubusercontent.com/manwar/Map-Tube-Tokyo/master/maps/Tokyo-Subway.png">
121 <img src = "https://raw.githubusercontent.com/manwar/Map-Tube-Tokyo/master/maps/Tokyo-Subway.png"
122 alt = "Tokyo Subway Map"
123 width = "1400px"
124 height = "700px"/>
125 </a>
126  
127 =end html
128  
129 =head1 AUTHOR
130  
131 Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >>
132  
133 =head1 REPOSITORY
134  
135 L<https://github.com/manwar/Map-Tube-Tokyo>
136  
137 =head1 BUGS
138  
139 Please report any bugs/feature requests to C<bug-map-tube-tokyo at rt.cpan.org>,
140 or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Map-Tube-Tokyo>.
141 I will be notified, and then you'll automatically be notified of progress on your
142 bug as I make changes.
143  
144 =head1 SUPPORT
145  
146 You can find documentation for this module with the perldoc command.
147  
148 perldoc Map::Tube::Tokyo
149  
150 You can also look for information at:
151  
152 =over 4
153  
154 =item * RT: CPAN's request tracker (report bugs here)
155  
156 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Map-Tube-Tokyo>
157  
158 =item * AnnoCPAN: Annotated CPAN documentation
159  
160 L<http://annocpan.org/dist/Map-Tube-Tokyo>
161  
162 =item * CPAN Ratings
163  
164 L<http://cpanratings.perl.org/d/Map-Tube-Tokyo>
165  
166 =item * Search CPAN
167  
168 L<http://search.cpan.org/dist/Map-Tube-Tokyo/>
169  
170 =back
171  
172 =head1 LICENSE AND COPYRIGHT
173  
174 Copyright (C) 2014 - 2016 Mohammad S Anwar.
175  
176 This program is free software; you can redistribute it and / or modify it under
177 the terms of the the Artistic License (2.0). You may obtain a copy of the full
178 license at:
179  
180 L<http://www.perlfoundation.org/artistic_license_2_0>
181  
182 Any use, modification, and distribution of the Standard or Modified Versions is
183 governed by this Artistic License.By using, modifying or distributing the Package,
184 you accept this license. Do not use, modify, or distribute the Package, if you do
185 not accept this license.
186  
187 If your Modified Version has been derived from a Modified Version made by someone
188 other than you,you are nevertheless required to ensure that your Modified Version
189 complies with the requirements of this license.
190  
191 This license does not grant you the right to use any trademark, service mark,
192 tradename, or logo of the Copyright Holder.
193  
194 This license includes the non-exclusive, worldwide, free-of-charge patent license
195 to make, have made, use, offer to sell, sell, import and otherwise transfer the
196 Package with respect to any patent claims licensable by the Copyright Holder that
197 are necessarily infringed by the Package. If you institute patent litigation
198 (including a cross-claim or counterclaim) against any party alleging that the
199 Package constitutes direct or contributory patent infringement,then this Artistic
200 License to you shall terminate on the date that such litigation is filed.
201  
202 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
203 CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
204 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
205 NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
206 REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
207 INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
208 OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
209  
210 =cut
211  
212 1; # End of Map::Tube::Tokyo
↑ Summary Tokyo/Line/Asakusa.pm »