| 1 | # | ||||||||||
| 2 | # This file is part of App-Magpie | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is copyright (c) 2011 by Jerome Quelin. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||
| 8 | # | ||||||||||
| 9 | 3 | ▶ | use 5.012; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | package App::Magpie::Role::RunningCommand; | ||||||||||
| 14 | # ABSTRACT: sthg that can run an external command | ||||||||||
| 15 | 3 | $App::Magpie::Role::RunningCommand::VERSION = '2.010'; | |||||||||
| 16 | 3 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 3 | ▶ | use MooseX::Has::Sugar; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 3 | with 'App::Magpie::Role::Logging'; | |||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | # -- public methods | ||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub run_command { | ||||||||
|
Subroutine
run_command: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 26 | 0 | my ($self, $cmd) = @_; | |||||||||
| 27 | 0 | my $logger = $self->logger; | |||||||||
| 28 | 0 | $self->log_debug( "running: $cmd" ); | |||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | my $stderr = $logger->log_level >= 2 ? "" : "2>/dev/null"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | # run the command | ||||||||||
| 33 | 0 | ▶ | system("$cmd $stderr >&2") == 0 | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | or $self->log_fatal( "command [$cmd] exited with value " . ($?>>8) ); | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | 3 | 1; | |||||||||
| 40 | |||||||||||
| 41 | __END__ | ||||||||||