line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
986
|
use 5.10.0; |
|
2
|
|
|
|
|
6
|
|
2
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
38
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
101
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Map::Metro::Shim; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Easily load a map file |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
9
|
|
|
|
|
|
|
our $VERSION = '0.2404'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
18
|
use Map::Metro::Elk; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
12
|
2
|
|
|
2
|
|
2693
|
use Types::Standard qw/ArrayRef/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
13
|
2
|
|
|
2
|
|
768
|
use Types::Path::Tiny qw/AbsFile/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
23
|
|
14
|
2
|
|
|
2
|
|
560
|
use Map::Metro::Graph; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
517
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has filepath => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => AbsFile, |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
coerce => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
has hooks => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => ArrayRef, |
25
|
|
|
|
|
|
|
traits => ['Array'], |
26
|
|
|
|
|
|
|
default => sub { [] }, |
27
|
|
|
|
|
|
|
handles => { |
28
|
|
|
|
|
|
|
all_hooks => 'elements', |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
around BUILDARGS => sub { |
33
|
|
|
|
|
|
|
my $orig = shift; |
34
|
|
|
|
|
|
|
my $class = shift; |
35
|
|
|
|
|
|
|
my @args = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return $class->$orig(@args) if scalar @args == 2; |
38
|
|
|
|
|
|
|
return $class->$orig(filepath => shift @args) if scalar @args == 1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my %args; |
41
|
|
|
|
|
|
|
if(scalar @args % 2 != 0) { |
42
|
|
|
|
|
|
|
my $filepath = shift @args; |
43
|
|
|
|
|
|
|
%args = @args; |
44
|
|
|
|
|
|
|
$args{'filepath'} = $filepath; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
|
|
|
|
|
|
%args = @args; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
if(exists $args{'hooks'} && !ArrayRef->check($args{'hooks'})) { |
50
|
|
|
|
|
|
|
$args{'hooks'} = [$args{'hooks'}]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return $class->$orig(%args); |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub parse { |
57
|
4
|
|
|
4
|
0
|
1547
|
my $self = shift; |
58
|
4
|
|
|
|
|
10
|
my %args = @_; |
59
|
4
|
50
|
|
|
|
11
|
my $override_line_change_weight = exists $args{'override_line_change_weight'} ? $args{'override_line_change_weight'} : 0; |
60
|
|
|
|
|
|
|
|
61
|
4
|
50
|
|
|
|
97
|
return Map::Metro::Graph->new(filepath => $self->filepath, |
62
|
|
|
|
|
|
|
wanted_hook_plugins => [$self->all_hooks], |
63
|
|
|
|
|
|
|
defined $override_line_change_weight ? (override_line_change_weight => $override_line_change_weight) : (), |
64
|
|
|
|
|
|
|
)->parse; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=pod |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding UTF-8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Map::Metro::Shim - Easily load a map file |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Version 0.2404, released 2016-04-30. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
use Map::Metro::Shim; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $graph = Map::Metro::Shim->new('../path/to/mapfile.txt')->parse; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
If you want to test a map file without creating a module, use this class instead of L<Map::Metro> and pass the path to the map file. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 Methods |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head3 new($filepath) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
B<C<$filepath>> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The path to the map file. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Apart from that this module works just like L<Map::Metro>. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L<Map::Metro> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SOURCE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-Map-Metro> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 HOMEPAGE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L<https://metacpan.org/release/Map-Metro> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
124
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |