blib/lib/Ubic/Run.pm

filter: Statementstmt 100% 34 / 34 Branchbran 81.2% 13 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 94.6% 53 / 56 SCAR 22.0
CC
9
Cov
94%
import
9.1
BEGIN
1.0
BEGIN
1.0
CRAP 9.0
« lib/Ubic/ServiceLoader/Ext/json.pm ↑ Summary lib/Ubic/Daemon/OS/Linux.pm »
1 package Ubic::Run;
2 33 $Ubic::Run::VERSION = '1.59';
3 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: really simple way to write init scripts
7  
8  
9 33 ▶use Ubic::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 33 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 33 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub import {
14 33 ▶ my $class = shift;
Subroutine import: called CC=9 SCAR=22.0
15 33 my ($name) = @_;
16 33 ▶ unless (defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 29 4 33
17 29 ▶ if ( $0 =~ m{^/etc/init\.d/(.+)$} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($0 =~ m[^/etc/init\.d/(.+)$]) { } 12 17 29
elsif ($0 =~ m[^/etc/rc\d\.d/(?:K|S)\d+(.+)$]) { } 8 9 17
elsif ($0 =~ m[^/etc/rc\.d/init\.d/(.+)$]) { } 8 1 9
18 12 $name = $1;
19 }
20 elsif ( $0 =~ m{^/etc/rc\d\.d/(?:K|S)\d+(.+)$} ) {
21 8 $name = $1;
22 }
23 elsif ( $0 =~ m{^/etc/rc\.d/init\.d/(.+)$} ) {
24 8 $name = $1;
25 }
26 else {
27 1 die "Strange \$0: $0";
28 }
29 }
30  
31 32 my $force;
32 32 ▶ GetOptions(
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("f|force", \$force) or die "Unknown option specified" 0 32 32
33 'f|force' => \$force,
34 ) or die "Unknown option specified";
35  
36 32 my ($command, @args) = @ARGV;
37 32 my @names;
38 32 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) { } 4 28 32
39 4 @names = map { "$name.$_" } @args;
40 }
41 else {
42 28 @names = ($name);
43 }
44 32 ▶ Ubic::Cmd->run({
Branch: 2 branches
BranchTrueFalseTotal
$command ? : 32 0 32
$force ? : 0 32 32
45 name => \@names,
46 ($command ? (command => $command) : ()),
47 ($force ? (force => $force) : ()),
48 });
49 }
50  
51  
52 33 1;
53  
54 __END__
« lib/Ubic/ServiceLoader/Ext/json.pm ↑ Summary lib/Ubic/Daemon/OS/Linux.pm »