File Coverage

blib/lib/Map/Tube/Barcelona.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


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