lib/Log/Munger/App/Command/which_rule_file.pm

filter: Statementstmt 88.0% 22 / 25 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 80.0% 4 / 5 totaltotal 83.7% 36 / 43 CC 3 SCAR 5.5
CC
3
Cov
86%
execute
3.0
abstract
2.0
description
2.0
CRAP 1.7
« lib/Log/Munger/App/Command/list.pm ↑ Summary lib/Log/Munger/App/Command/rule_file_template_order.pm »
1 package Log::Munger::App::Command::which_rule_file;
2  
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use Log::Munger::App -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use Log::Munger::WhichRuleFile;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶sub opt_spec {
Subroutine opt_spec: called CC=1 SCAR=0.0
Pod documented
9 2 return ( [ 'f=s', 'Rule file to locate.' ], );
10 }
11  
12 0 ▶sub abstract { "Print the path a rule file name resolves to" }
Subroutine abstract: not called CC=1 SCAR=6.9
Pod documented
13  
14 0 ▶sub description {
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
15 0 "Prints the path a rule file name resolves to, searching the directory named by the
16 LOG_MUNGER_RULES_DIR environment variable (when set), then /etc/log_munger/rules, then
17 /usr/local/etc/log_munger/rules, then the dist share dir. A name beginning with /, ./, or ../ is
18 used as a path instead of being searched for.
19  
20 Exit codes:
21 - 0 :: found
22 - 1 :: not found
23 - 255 :: error
24 ";
25 } ## end sub description
26  
27 2 ▶sub validate { return 1 }
Subroutine validate: called CC=1 SCAR=0.0
Pod undocumented
28  
29 2 ▶sub execute {
Subroutine execute: called CC=3 SCAR=11.1
Pod documented
30 2 my ( $self, $opts, $args ) = @_;
31  
32 2 ▶ if ( !defined( $opts->{'f'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts->{"f"}) 0 2 2
33 0 die('Nothing specified for -f');
34 }
35  
36 2 my $file_location = Log::Munger::WhichRuleFile->rule_file_location( 'file' => $opts->{'f'} );
37  
38 2 ▶ if ( !defined($file_location) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file_location) 1 1 2
39 1 exit 1;
40 }
41  
42 1 print $file_location. "\n";
43  
44 1 exit 0;
45 } ## end sub execute
46  
47 16 1;
« lib/Log/Munger/App/Command/list.pm ↑ Summary lib/Log/Munger/App/Command/rule_file_template_order.pm »