Metro/Shim.pm

filter: Statementstmt 95.5% 43 / 45 Branchbran 58.3% 7 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 83.5% 61 / 73 CC 8 SCAR 12.3
CC
8
Cov
85%
__ANON__
6.8
parse
3.1
BEGIN
1.0
CRAP 3.4
« Metro/Cmd/MetroToTube.pm ↑ Summary Metro/Plugin/Map.pm »
1 11 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Map::Metro::Shim;
6  
7 # ABSTRACT: Easily load a map file
8 11 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 11 our $VERSION = '0.2404';
10  
11 11 ▶use Map::Metro::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 11 ▶use Types::Standard qw/ArrayRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 11 ▶use Types::Path::Tiny qw/AbsFile/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 11 ▶use Map::Metro::Graph;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 11 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 4 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
27 11 handles => {
28 all_hooks => 'elements',
29 }
30 );
31  
32 around BUILDARGS => sub {
33 4 ▶ my $orig = shift;
Subroutine __ANON__: called CC=6 SCAR=19.2
34 4 my $class = shift;
35 4 my @args = @_;
36  
37 4 ▶ return $class->$orig(@args) if scalar @args == 2;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @args == 2 0 4 4
38 4 ▶ return $class->$orig(filepath => shift @args) if scalar @args == 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @args == 1 2 2 4
39  
40 2 my %args;
41 2 ▶ if(scalar @args % 2 != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args % 2 != 0) { } 2 0 2
42 2 my $filepath = shift @args;
43 2 %args = @args;
44 2 $args{'filepath'} = $filepath;
45 }
46 else {
47 0 %args = @args;
48 }
49 2 ▶ if(exists $args{'hooks'} && !ArrayRef->check($args{'hooks'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"hooks"} and not &ArrayRef()->check($args{"hooks"})) 0 2 2
Condition33%1/3
exists $args{"hooks"} and not &ArrayRef()->check($args{"hooks"})
!ll&&!rl&&r
200
MC/DC0%0/2
exists $args{"hooks"} and not &ArrayRef()->check($args{"hooks"})
exists $args{"hooks"} not &ArrayRef()->check($args{"hooks"})
Truth table33%1/3
A and not(B)
A= exists $args{"hooks"}B= not &ArrayRef()->check($args{"hooks"})
ABresult
0X0
100
111
50 0 $args{'hooks'} = [$args{'hooks'}];
51 }
52  
53 2 return $class->$orig(%args);
54 11 };
55  
56 sub parse {
57 4 ▶ my $self = shift;
Subroutine parse: called CC=3 SCAR=11.4
Pod undocumented
58 4 my %args = @_;
59 4 ▶ my $override_line_change_weight = exists $args{'override_line_change_weight'} ? $args{'override_line_change_weight'} : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'override_line_change_weight'} ? : 0 4 4
60  
61 4 ▶ return Map::Metro::Graph->new(filepath => $self->filepath,
Branch: 1 branch
BranchTrueFalseTotal
defined $override_line_change_weight ? : 4 0 4
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 11 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
« Metro/Cmd/MetroToTube.pm ↑ Summary Metro/Plugin/Map.pm »