File Coverage

blib/lib/Map/Tube/Plugin/Graph.pm
Criterion Covered Total %
statement 6 8 75.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 9 11 81.8


line stmt bran cond sub pod time code
1             package Map::Tube::Plugin::Graph;
2              
3             $Map::Tube::Plugin::Graph::VERSION = '0.27';
4             $Map::Tube::Plugin::Graph::AUTHORITY = 'cpan:MANWAR';
5              
6             =head1 NAME
7              
8             Map::Tube::Plugin::Graph - Graph plugin for Map::Tube.
9              
10             =head1 VERSION
11              
12             Version 0.27
13              
14             =cut
15              
16 1     1   45949 use 5.006;
  1         4  
17 1     1   342 use Data::Dumper;
  1         4949  
  1         59  
18 1     1   314 use Map::Tube::Plugin::Graph::Utils qw(graph_line_image graph_map_image);
  0            
  0            
19              
20             use Moo::Role;
21             use namespace::clean;
22              
23             =head1 DESCRIPTION
24              
25             It's a graph plugin for L to create map of individual lines defined as
26             Moo Role. Once installed, it gets plugged into Map::Tube::* family.
27              
28             =head1 SYNOPSIS
29              
30             use strict; use warnings;
31             use MIME::Base64;
32             use Map::Tube::London;
33              
34             my $tube = Map::Tube::London->new;
35              
36             # Entire map image
37             my $name = $tube->name;
38             open(my $MAP_IMAGE, ">$name.png");
39             binmode($MAP_IMAGE);
40             print $MAP_IMAGE decode_base64($tube->as_image);
41             close($MAP_IMAGE);
42              
43             # Just a particular line map image
44             my $line = 'Bakerloo';
45             open(my $LINE_IMAGE, ">$line.png");
46             binmode($LINE_IMAGE);
47             print $LINE_IMAGE decode_base64($tube->as_image($line));
48             close($LINE_IMAGE);
49              
50             =head1 INSTALLATION
51              
52             The plugin primarily depends on GraphViz2 library. But the GraphViz2 can only be
53             installed if the perl v5.014002 or above is installed. If your perl environment
54             satisfies this requirement then ignore the rest of instructions.
55              
56             Having said that I still managed to install GraphViz2 on my box with perl 5.10.1.
57             It requires a bit of nasty hack. If you are willing to do then follow the steps
58             below:
59              
60             =over 2
61              
62             =item * Download the tar ball from CPAN.
63             e.g.
64             wget http://search.cpan.org/CPAN/authors/id/R/RS/RSAVAGE/GraphViz2-2.34.tgz
65              
66             =item * Extract the tar ball i.e. tar -xvzf GraphViz2-2.34.tgz
67              
68             =item * Change directory to GraphViz2-2.34 i.e. cd GraphViz2-2.34
69              
70             =item * Edit the Makefile.PL and comment the line (no: 11) that says:
71             require 5.014002; # For the utf8 stuff.
72              
73             =item * Now follow the usual command to make/test/install. If it complains about
74             missing package then install it on demand one at a time.
75              
76             =back
77              
78             =head1 METHODS
79              
80             =head2 as_image($line_name)
81              
82             The C<$line_name> param is optional.If it's passed, the method returns the base64
83             encoded string of the given line map. Otherwise you would get the entire map as
84             base64 encoded string.
85              
86             See SYNOPSIS for more details on how it can be used.
87              
88             =cut
89              
90             sub as_image {
91             my ($self, $line_name) = @_;
92              
93             (defined $line_name)
94             ?
95             (return graph_line_image($self, $line_name))
96             :
97             (return graph_map_image($self));
98             }
99              
100             =head1 AUTHOR
101              
102             Mohammad S Anwar, C<< >>
103              
104             =head1 REPOSITORY
105              
106             L
107              
108             =head1 SEE ALSO
109              
110             =over 4
111              
112             =item * L
113              
114             =item * L
115              
116             =back
117              
118             =head1 CONTRIBUTORS
119              
120             =over 2
121              
122             =item * Gisbert W. Selke
123              
124             =back
125              
126             =head1 BUGS
127              
128             Please report any bugs or feature requests to C, or
129             through the web interface at L.
130             I will be notified and then you'll automatically be notified of progress on your
131             bug as I make changes.
132              
133             =head1 SUPPORT
134              
135             You can find documentation for this module with the perldoc command.
136              
137             perldoc Map::Tube::Plugin::Graph
138              
139             You can also look for information at:
140              
141             =over 4
142              
143             =item * RT: CPAN's request tracker (report bugs here)
144              
145             L
146              
147             =item * AnnoCPAN: Annotated CPAN documentation
148              
149             L
150              
151             =item * CPAN Ratings
152              
153             L
154              
155             =item * Search CPAN
156              
157             L
158              
159             =back
160              
161             =head1 LICENSE AND COPYRIGHT
162              
163             Copyright (C) 2015 - 2017 Mohammad S Anwar.
164              
165             This program is free software; you can redistribute it and / or modify it under
166             the terms of the the Artistic License (2.0). You may obtain a copy of the full
167             license at:
168              
169             L
170              
171             Any use, modification, and distribution of the Standard or Modified Versions is
172             governed by this Artistic License.By using, modifying or distributing the Package,
173             you accept this license. Do not use, modify, or distribute the Package, if you do
174             not accept this license.
175              
176             If your Modified Version has been derived from a Modified Version made by someone
177             other than you,you are nevertheless required to ensure that your Modified Version
178             complies with the requirements of this license.
179              
180             This license does not grant you the right to use any trademark, service mark,
181             tradename, or logo of the Copyright Holder.
182              
183             This license includes the non-exclusive, worldwide, free-of-charge patent license
184             to make, have made, use, offer to sell, sell, import and otherwise transfer the
185             Package with respect to any patent claims licensable by the Copyright Holder that
186             are necessarily infringed by the Package. If you institute patent litigation
187             (including a cross-claim or counterclaim) against any party alleging that the
188             Package constitutes direct or contributory patent infringement,then this Artistic
189             License to you shall terminate on the date that such litigation is filed.
190              
191             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
192             CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
193             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
194             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
195             REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
196             INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
197             OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
198              
199             =cut
200              
201             1; # End of Map::Tube::Plugin::Graph