File Coverage

blib/lib/Sys/CmdMod/Plugin/Nice.pm
Criterion Covered Total %
statement 11 13 84.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 16 18 88.8


line stmt bran cond sub pod time code
1             package Sys::CmdMod::Plugin::Nice;
2             {
3             $Sys::CmdMod::Plugin::Nice::VERSION = '0.18';
4             }
5             BEGIN {
6 1     1   1789 $Sys::CmdMod::Plugin::Nice::AUTHORITY = 'cpan:TEX';
7             }
8             # ABSTRACT: CmdMod Plugin for nice
9              
10 1     1   27 use 5.010_000;
  1         3  
  1         40  
11 1     1   6 use mro 'c3';
  1         2  
  1         6  
12 1     1   47 use feature ':5.10';
  1         1  
  1         95  
13              
14 1     1   462 use Moose;
  0            
  0            
15             use namespace::autoclean;
16              
17             # use IO::Handle;
18             # use autodie;
19             # use MooseX::Params::Validate;
20              
21             extends 'Sys::CmdMod::Plugin';
22              
23             has 'niceness' => (
24             'is' => 'rw',
25             'isa' => 'Num',
26             'default' => 19,
27             );
28              
29             sub _init_priority { return 10; }
30              
31             sub BUILD {
32             my $self = shift;
33              
34             if ( !-x $self->binary() ) {
35             die( 'Could not find nice executable at ' . $self->binary() );
36             }
37             }
38              
39             sub _init_binary {
40             my $self = shift;
41              
42             return $self->_find_binary('nice');
43             }
44              
45             sub cmd {
46             my $self = shift;
47             my $cmd = shift;
48             return $self->binary() . ' -n ' . $self->niceness() . q{ } . $cmd;
49             }
50              
51             no Moose;
52             __PACKAGE__->meta->make_immutable;
53              
54             1;
55              
56             __END__
57              
58             =pod
59              
60             =encoding utf-8
61              
62             =head1 NAME
63              
64             Sys::CmdMod::Plugin::Nice - CmdMod Plugin for nice
65              
66             =head1 NAME
67              
68             Sys::CmdMod::Plugin::Nice - nice processes
69              
70             =head1 METHODS
71              
72             =head2 BUILD
73              
74             Initialize this module.
75              
76             =head2 cmd
77              
78             Prepend the nice invocation.
79              
80             =head1 AUTHOR
81              
82             Dominik Schulz <dominik.schulz@gauner.org>
83              
84             =head1 COPYRIGHT AND LICENSE
85              
86             This software is copyright (c) 2012 by Dominik Schulz.
87              
88             This is free software; you can redistribute it and/or modify it under
89             the same terms as the Perl 5 programming language system itself.
90              
91             =cut