| 1 | package Silki::Util; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 8 | $Silki::Util::VERSION = '0.29'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use File::Which qw( which ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Path::Class qw( file ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 8 | our @EXPORT_OK = qw( string_is_empty english_list detach_and_run ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 30 | ▶ | sub string_is_empty { | ||||||||||||||||||||||||||
|
Subroutine
string_is_empty: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 30 | ▶ | return 1 if !defined $_[0] || !length $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_[0] and length $_[0]
MC/DC100%2/2
defined $_[0] and length $_[0]
defined $_[0]
length $_[0]
Truth table100%3/3
A and B
A= defined $_[0]B= length $_[0]
| |||||||||||||||||||||||||||||
| 18 | 8 | return 0; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | sub english_list { | ||||||||||||||||||||||||||
|
Subroutine
english_list: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | return $_[0] if @_ <= 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | return join ' and ', @_ if @_ == 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | my $last = pop @_; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | return ( join ', ', @_ ) . ', and ' . $last; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub detach_and_run { | ||||||||||||||||||||||||||
|
Subroutine
detach_and_run: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 0 | my $executable = _find_executable( $_[0] ); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | return if fork; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | require POSIX; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | exit 1 unless POSIX::setsid(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ( Silki::Schema->can('DBIManager') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | $_->dbh()->{InactiveDestroy} = 1 | ||||||||||||||||||||||||||||
| 41 | 0 | for Silki::Schema->DBIManager()->sources(); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | local $ENV{PERL5LIB} = join ':', @INC; | |||||||||||||||||||||||||||
| 45 | 0 | exec {$executable} @_; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | die "Could not exec - $executable @_: $!"; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub _find_executable { | ||||||||||||||||||||||||||
|
Subroutine
_find_executable: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 51 | 0 | my $executable = shift; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | my $path = which($executable); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | return $path if $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my $rel = file( 'bin', $executable ); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | return $rel if -x $rel; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | die "Cannot find an executable named $executable"; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 8 | 1; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # ABSTRACT: A utility module | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||