| 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; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # ABSTRACT: Public transport graphing | ||||||||||||||||||||||||||||
| 8 | 11 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||||||||||
| 9 | 11 | our $VERSION = '0.2405'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use Map::Metro::Elk; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use Module::Pluggable search_path => ['Map::Metro::Plugin::Map'], require => 1, sub_name => 'system_maps'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use Types::Standard qw/ArrayRef Str/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 11 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 11 | ▶ | use List::Util qw/any/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 11 | ▶ | use Map::Metro::Graph; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 11 | ▶ | use Map::Metro::Exceptions; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 11 | has map => ( | |||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||
| 22 | traits => ['Array'], | ||||||||||||||||||||||||||||
| 23 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 24 | predicate => 1, | ||||||||||||||||||||||||||||
| 25 | handles => { | ||||||||||||||||||||||||||||
| 26 | get_map => 'get', | ||||||||||||||||||||||||||||
| 27 | }, | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | has mapclasses => ( | ||||||||||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||||||||||
| 31 | traits => ['Array'], | ||||||||||||||||||||||||||||
| 32 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 33 | 1 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 11 | handles => { | |||||||||||||||||||||||||||
| 35 | add_mapclass => 'push', | ||||||||||||||||||||||||||||
| 36 | get_mapclass => 'get', | ||||||||||||||||||||||||||||
| 37 | }, | ||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | has hooks => ( | ||||||||||||||||||||||||||||
| 40 | is => 'ro', | ||||||||||||||||||||||||||||
| 41 | isa => ArrayRef[ Str ], | ||||||||||||||||||||||||||||
| 42 | traits => ['Array'], | ||||||||||||||||||||||||||||
| 43 | 1 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 11 | handles => { | |||||||||||||||||||||||||||
| 45 | all_hooks => 'elements', | ||||||||||||||||||||||||||||
| 46 | hook_count => 'count', | ||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | 11 | has _plugin_ns => ( | |||||||||||||||||||||||||||
| 50 | is => 'ro', | ||||||||||||||||||||||||||||
| 51 | isa => Str, | ||||||||||||||||||||||||||||
| 52 | default => 'Plugin::Map', | ||||||||||||||||||||||||||||
| 53 | init_arg => undef, | ||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=26.3
| |||||||||||||||||||||||||||||
| 57 | 1 | my ($orig, $class, @args) = @_; | |||||||||||||||||||||||||||
| 58 | 1 | my %args; | |||||||||||||||||||||||||||
| 59 | 1 | ▶ | if(scalar @args == 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 60 | 1 | $args{'map'} = shift @args; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | elsif(scalar @args % 2 != 0) { | ||||||||||||||||||||||||||||
| 63 | 0 | my $map = shift @args; | |||||||||||||||||||||||||||
| 64 | 0 | %args = @args; | |||||||||||||||||||||||||||
| 65 | 0 | $args{'map'} = $map; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||
| 68 | 0 | %args = @args; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | ▶ | if(exists $args{'map'} && !ArrayRef->check($args{'map'})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $args{"map"} and not &ArrayRef()->check($args{"map"})
MC/DC0%0/2
exists $args{"map"} and not &ArrayRef()->check($args{"map"})
exists $args{"map"}
not &ArrayRef()->check($args{"map"})
Truth table33%1/3
A and not(B)
A= exists $args{"map"}B= not &ArrayRef()->check($args{"map"})
| |||||||||||||||||||||||||||||
| 72 | 1 | $args{'map'} = [$args{'map'}]; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 1 | ▶ | if(exists $args{'hooks'} && !ArrayRef->check($args{'hooks'})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $args{"hooks"} and not &ArrayRef()->check($args{"hooks"})
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"})
| |||||||||||||||||||||||||||||
| 75 | 0 | $args{'hooks'} = [$args{'hooks'}]; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | return $class->$orig(%args); | |||||||||||||||||||||||||||
| 79 | 11 | }; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 83 | 1 | my @args = @_; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1 | ▶ | if($self->has_map) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | my @system_maps = map { s{^Map::Metro::Plugin::Map::}{}; $_ } $self->system_maps; | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | if(any { $_ eq $self->get_map(0) } @system_maps) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | my $mapclass = 'Map::Metro::Plugin::Map::'.$self->get_map(0); | |||||||||||||||||||||||||||
| 89 | 0 | my $mapobj = $mapclass->new(hooks => $self->hooks); | |||||||||||||||||||||||||||
| 90 | 0 | $self->add_mapclass($mapobj); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||
| 93 | 1 | ▶ | try { die no_such_map mapname => $self->get_map(0) } catch { die $_->desc }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # Borrowed from Mojo::Util | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub decamelize { | ||||||||||||||||||||||||||
|
Subroutine
decamelize: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 101 | 0 | my $string = shift; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | return $string if $string !~ m{[A-Z]}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | return join '_' => map { | ||||||||||||||||||||||||||||
| 105 | 0 | join ('_' => map { lc } grep { length } split m{([A-Z]{1}[^A-Z]*)}) | |||||||||||||||||||||||||||
| 106 | } split '::' => $string; | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 111 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | return Map::Metro::Graph->new(filepath => $self->get_mapclass(0)->maplocation, | ||||||||||||||||||||||||||||
| 114 | do_undiacritic => $self->get_mapclass(0)->do_undiacritic, | ||||||||||||||||||||||||||||
| 115 | wanted_hook_plugins => [$self->all_hooks], | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | exists $args{'override_line_change_weight'} ? (override_line_change_weight => $args{'override_line_change_weight'}) : (), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | )->parse; | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub available_maps { | ||||||||||||||||||||||||||
|
Subroutine
available_maps: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 122 | 0 | return sort $self->system_maps; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 11 | 1; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | __END__ | ||||||||||||||||||||||||||||