File Coverage

blib/lib/Sys/CmdMod/Plugin.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;
2             {
3             $Sys::CmdMod::Plugin::VERSION = '0.18';
4             }
5             BEGIN {
6 1     1   1234 $Sys::CmdMod::Plugin::AUTHORITY = 'cpan:TEX';
7             }
8             # ABSTRACT: Abstract base class for command modifier
9              
10 1     1   16 use 5.010_000;
  1         2  
  1         31  
11 1     1   5 use mro 'c3';
  1         1  
  1         11  
12 1     1   21 use feature ':5.10';
  1         1  
  1         72  
13              
14 1     1   307 use Moose;
  0            
  0            
15             use namespace::autoclean;
16              
17             # use IO::Handle;
18             # use autodie;
19             # use MooseX::Params::Validate;
20              
21             use Sys::Run;
22              
23             has 'name' => (
24             'is' => 'ro',
25             'isa' => 'Str',
26             'required' => 1,
27             );
28              
29             has 'binary' => (
30             'is' => 'ro',
31             'isa' => 'Str',
32             'lazy' => 1,
33             'builder' => '_init_binary',
34             );
35              
36             has 'sys' => (
37             'is' => 'rw',
38             'isa' => 'Sys::Run',
39             'lazy' => 1,
40             'builder' => '_init_sys',
41             );
42              
43             has 'priority' => (
44             'is' => 'ro',
45             'isa' => 'Int',
46             'lazy' => 1,
47             'builder' => '_init_priority',
48             );
49              
50             with qw(Log::Tree::RequiredLogger);
51              
52             sub _init_priority { return 0; }
53              
54             sub _init_sys {
55             my $self = shift;
56              
57             my $Sys = Sys::Run::->new( { 'logger' => $self->logger(), } );
58              
59             return $Sys;
60             }
61              
62             # this baseclass just passes the given commands through
63             sub cmd {
64             my @cmd = @_;
65             return @cmd;
66             }
67              
68             sub _find_binary {
69             my $self = shift;
70             my $binary = shift;
71              
72             return $self->sys()->check_binary($binary);
73             }
74              
75             no Moose;
76             __PACKAGE__->meta->make_immutable;
77              
78             1;
79              
80             __END__
81              
82             =pod
83              
84             =encoding utf-8
85              
86             =head1 NAME
87              
88             Sys::CmdMod::Plugin - Abstract base class for command modifier
89              
90             =head1 METHODS
91              
92             =head2 cmd
93              
94             Subclasses MUST implement this method.
95              
96             This methods MUST return the command list passed to it.
97              
98             Subclasses SHOULD prepend their own commands to this list.
99              
100             =head1 NAME
101              
102             Sys::CmdMod - Abstract base class for command modifier
103              
104             =head1 AUTHOR
105              
106             Dominik Schulz <dominik.schulz@gauner.org>
107              
108             =head1 COPYRIGHT AND LICENSE
109              
110             This software is copyright (c) 2012 by Dominik Schulz.
111              
112             This is free software; you can redistribute it and/or modify it under
113             the same terms as the Perl 5 programming language system itself.
114              
115             =cut