blib/lib/Clustericious/Command/which.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 54 / 54 CC 6 SCAR 13.2
CC
6
Cov
100%
run
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« blib/lib/Clustericious/Config/Helpers.pm ↑ Summary blib/lib/Clustericious/Controller.pm »
1 package Clustericious::Command::which;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Sub::Identify 0.05 qw( get_code_location get_code_info );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Mojo::Base qw( Clustericious::Command );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Clustericious command to start a Clustericious application
10 6 our $VERSION = '1.29'; # VERSION
11  
12 6 has description => <<EOT;
13 Determine the location of method or helper.
14 EOT
15  
16 6 has usage => <<EOT;
17 usage $0: which method
18 EOT
19  
20 sub run
21 6 ▶{
Subroutine run: called CC=6 SCAR=17.9
Pod documented
22 6 my($self, $method) = @_;
23 6 my $app = $self->app;
24 6 my $controller = $app->build_controller;
25
26 6 ▶ unless($method)
Branch: 1 branch
BranchTrueFalseTotal
unless ($method) 1 5 6
27 {
28 1 say STDERR "no method specified";
29 1 exit 1;
30 }
31
32 5 my $type;
33 my $sub;
34
35 5 ▶ if($sub = $controller->can($method))
Branch: 3 branches
BranchTrueFalseTotal
if ($sub = $controller->can($method)) { } 1 4 5
elsif ($sub = $app->renderer->get_helper($method)) { } 2 2 4
elsif ($sub = $app->can($method)) { } 1 1 2
36 {
37 1 $type = "controller method";
38 }
39 elsif($sub = $app->renderer->get_helper($method))
40 {
41 2 $type = "helper";
42 }
43 elsif($sub = $app->can($method))
44 {
45 1 $type = "app method";
46 }
47 else
48 {
49 1 say STDERR "No such method or helper: $method";
50 1 exit 2;
51 }
52  
53 4 my($class, $name) = get_code_info $sub;
54 4 my($file, $line) = get_code_location $sub;
55
56 4 say "type: $type";
57 4 say "class: $class";
58 4 ▶ say "name: $name" if $name ne '__ANON__';
Branch: 1 branch
BranchTrueFalseTotal
if $name ne "__ANON__" 3 1 4
59 4 say "location: $file:$line";
60 }
61  
62 6 1;
63  
64 __END__
« blib/lib/Clustericious/Config/Helpers.pm ↑ Summary blib/lib/Clustericious/Controller.pm »