File Coverage

blib/lib/Ixchel/Actions/perl_module_via_pkg.pm
Criterion Covered Total %
statement 14 28 50.0
branch 0 4 0.0
condition n/a
subroutine 5 9 55.5
pod 2 4 50.0
total 21 45 46.6


line stmt bran cond sub pod time code
1             package Ixchel::Actions::perl_module_via_pkg;
2              
3 1     1   78360 use 5.006;
  1         3  
4 1     1   4 use strict;
  1         2  
  1         20  
5 1     1   3 use warnings;
  1         1  
  1         44  
6 1     1   383 use Ixchel::functions::perl_module_via_pkg;
  1         6  
  1         78  
7 1     1   6 use base 'Ixchel::Actions::base';
  1         1  
  1         37  
8              
9             =head1 NAME
10              
11             Ixchel::Actions::perl_module_via_pkg - Install Perl modules via the package manager.
12              
13             =head1 VERSION
14              
15             Version 0.3.0
16              
17             =cut
18              
19             our $VERSION = '0.3.0';
20              
21             =head1 CLI SYNOPSIS
22              
23             ixchel -a perl_module_via_pkg B<--module>
24              
25             =head1 CODE SYNOPSIS
26              
27             my $results=$ixchel->action(action=>'perl_module_via_pkg', opts=>{module=>'Monitoring::Sneck'});
28              
29             if ($results->{ok}) {
30             print $results->{status_text};
31             }else{
32             die('Action errored... '.joined("\n", @{$results->{errors}}));
33             }
34              
35             =head1 FLAGS
36              
37             =head2 --module
38              
39             The module to install.
40              
41             This must be specified.
42              
43             =head1 RESULT HASH REF
44              
45             .errors :: A array of errors encountered.
46             .status_text :: A string description of what was done and the results.
47             .ok :: Set to zero if any of the above errored.
48              
49             =cut
50              
51       0 0   sub new_extra { }
52              
53             sub action_extra {
54 0     0 0   my $self = $_[0];
55              
56 0 0         if ( !defined( $self->{opts}{module} ) ) {
57 0           $self->status_add(
58             status => '--module is undef',
59             error => 1
60             );
61 0           return undef;
62             }
63              
64 0           $self->status_add( status => 'Installing cpanm via packges' );
65              
66 0           my $status;
67 0           eval { $status = perl_module_via_pkg( module => $self->{opts}{module} ); };
  0            
68 0 0         if ($@) {
69             $self->status_add(
70 0           status => 'Failed to install ' . $self->{opts}{module} . ' via packages' . $@,
71             error => 1
72             );
73             } else {
74 0           $self->status_add( status => $self->{opts}{module} . ' installed' );
75             }
76              
77 0           return undef;
78             } ## end sub action_extra
79              
80             sub short {
81 0     0 1   return 'Install a Perl module via packages';
82             }
83              
84             sub opts_data {
85 0     0 1   return '
86             module=s
87             ';
88             }
89              
90             1;