Metro/Cmd/Lines.pm

filter: Statementstmt 49.0% 27 / 55 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod n/a totaltotal 46.5% 34 / 73 CC 8 SCAR 28.6
CC
8
Cov
43%
line
42.0
run
12.0
__ANON__
2.0
CRAP 17.5
« Metro/Cmd/Stations.pm ↑ Summary Metro/Graph.pm »
1 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Map::Metro::Cmd::Lines;
6  
7 # ABSTRACT: Display lines in the map
8 1 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 1 our $VERSION = '0.2405';
10  
11 1 ▶use Map::Metro::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use MooseX::App::Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 extends 'Map::Metro::Cmd';
14 1 ▶use List::Util qw/all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Types::Standard qw/Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 parameter cityname => (
18 is => 'rw',
19 isa => Str,
20 documentation => 'The name of the city',
21 required => 1,
22 );
23  
24 1 command_short_description 'Display line information in $city';
25  
26 0 ▶sub run {
Subroutine run: not called CC=3 SCAR=24.8
27 0 my $self = shift;
28 0 ▶ my $graph = $self->cityname !~ m{\.} ? Map::Metro->new($self->cityname)->parse : Map::Metro::Shim->new($self->cityname)->parse;
Branch: 1 branch
BranchTrueFalseTotal
!($self->cityname =~ /\./) ? : 0 0 0
29 0 $graph->all_pairs;
30  
31 0 foreach my $line ($graph->all_lines) {
32 0 say $self->line($graph, $line);
33 }
34 }
35  
36 0 ▶sub line {
Subroutine line: not called CC=6 SCAR=37.4
37 0 my $self = shift;
38 0 my $graph = shift;
39 0 my $line = shift;
40  
41 0 my @all_first_routes = sort { $b->step_count <=> $a->step_count } map { $_->get_route(0) } $graph->all_routings;
42  
43 0 my $chosen_route;
44  
45 ROUTE:
46 0 foreach my $route (@all_first_routes) {
47 0 my @step_line_ids = map { $_->origin_line_station->line->id } $route->all_steps;
48  
49 0 ▶ if(all { $_ eq $line->id} @step_line_ids) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&all(sub { $_ eq $line->id; } , @step_line_ids)) 0 0 0
50 0 $chosen_route = $route;
51 0 last ROUTE;
52 }
53 }
54 0 ▶ die sprintf "No good route found for line", $line->id if !$chosen_route;
Branch: 1 branch
BranchTrueFalseTotal
unless $chosen_route 0 0 0
55  
56 0 say '';
57 0 my $header = sprintf '%s: %s' => $line->name, $line->description;
58 0 say $header;
59 0 say '=' x length $header;
60 0 foreach my $step ($chosen_route->all_steps) {
61 0 say $step->origin_line_station->station->name;
62  
63 0 ▶ if(!$step->has_next_step) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($step->has_next_step) 0 0 0
64 0 say $step->destination_line_station->station->name;
65 }
66 }
67 }
68  
69 1 __PACKAGE__->meta->make_immutable;
70  
71 1 1;
72  
73 __END__
« Metro/Cmd/Stations.pm ↑ Summary Metro/Graph.pm »