File Coverage

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