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