| 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::Route; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | # ABSTRACT: Search in a map | ||||||||||||||||||||
| 8 | 1 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||
| 9 | 1 | our $VERSION = '0.2404'; | |||||||||||||||||||
| 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 Types::Standard qw/Str/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 1 | ▶ | use Safe::Isa qw/$_call_if_object/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 1 | parameter cityname => ( | |||||||||||||||||||
| 19 | is => 'rw', | ||||||||||||||||||||
| 20 | isa => Str, | ||||||||||||||||||||
| 21 | documentation => 'The name of the city you want to search in', | ||||||||||||||||||||
| 22 | required => 1, | ||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||
| 24 | 1 | parameter origin => ( | |||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||
| 26 | isa => Str, | ||||||||||||||||||||
| 27 | documentation => 'Start station', | ||||||||||||||||||||
| 28 | required => 1, | ||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||
| 30 | 1 | parameter destination => ( | |||||||||||||||||||
| 31 | is => 'rw', | ||||||||||||||||||||
| 32 | isa => Str, | ||||||||||||||||||||
| 33 | documentation => 'Final station', | ||||||||||||||||||||
| 34 | required => 1, | ||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 1 | command_short_description 'Search in a map'; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | sub run { | ||||||||||||||||||||
| 40 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | my %hooks = (hooks => ['PrettyPrinter']); | |||||||||||||||||||
| 43 | 0 | ▶ | my $graph = $self->cityname !~ m{\.} ? Map::Metro->new($self->cityname, %hooks)->parse : Map::Metro::Shim->new($self->cityname, %hooks)->parse; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | try { | ||||||||||||||||||||
| 46 | 0 | ▶ | $graph->routing_for($self->origin, $self->destination); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | catch { | ||||||||||||||||||||
| 49 | 0 | ▶ | my $error = $_; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 50 | 0 | say sprintf q{Try search by station id. Run '%s stations %s' to see station ids.}, $0, $self->cityname; | |||||||||||||||||||
| 51 | 0 | ▶ | die($_->$_call_if_object('desc') || $_); | ||||||||||||||||||
|
Condition0%0/3
$_->$Map::Metro::Cmd::Route::_call_if_object('desc') || $_
MC/DC0%0/2
$_->$Map::Metro::Cmd::Route::_call_if_object('desc') || $_
$_->$Map::Metro::Cmd::Route::_call_if_object('desc')
$_
Truth table0%0/3
A || B
A= $_->$Map::Metro::Cmd::Route::_call_if_object('desc')B= $_
| |||||||||||||||||||||
| 52 | 0 | }; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 1 | 1; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =pod | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =encoding UTF-8 | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =head1 NAME | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | Map::Metro::Cmd::Route - Search in a map | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =head1 VERSION | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | Version 0.2404, released 2016-04-30. | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =head1 SOURCE | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | L<https://github.com/Csson/p5-Map-Metro> | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =head1 HOMEPAGE | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | L<https://metacpan.org/release/Map-Metro> | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =head1 AUTHOR | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | Erik Carlsson <info@code301.com> | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | This software is copyright (c) 2016 by Erik Carlsson. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 90 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||