CpanMinus.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 42 CC 5 SCAR 30.9
CC
5
Cov
0%
register
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 22.0
1 package Devel::IPerl::Plugin::CpanMinus;
2  
3 use strict;
4 use warnings;
5  
6 our $VERSION = '0.01';
7  
8 sub register {
9 my ($class, $iperl) = @_;
10  
11 my $options = {
12 cpanm => [],
13 cpanm_info => [cmd => 'info'],
14 cpanm_installdeps => [installdeps => 1],
15 };
16  
17 $iperl->load_plugin('Perlbrew') unless $iperl->can('perlbrew');
18  
19 for my $name (qw{cpanm cpanm_info cpanm_installdeps}) {
20 $iperl->helper($name => sub {
21 my ($ip, $ret, %env) = (shift, -1);
22 eval 'require App::cpanminus::fatscript; 1;';
23 return $ret if $@;
24 return $ret if 0 == @_; # nothing to do?
25 my @filtered = @_;
26 my $cpanm = App::cpanminus::script->new(
27 @{$options->{$name}},
28 argv => [@filtered]);
29 $cpanm->parse_options();
30 $cpanm->{interactive} = 0;
31 delete $cpanm->{action}
32 if exists $cpanm->{action} and $cpanm->{action} =~ m/upgrade/;
33 return $cpanm->doit;
34 });
35 }
36 return 1;
37 }
38  
39 1;
40  
41 =pod
42  
43 =head1 NAME
44  
45 Devel::IPerl::Plugin::CpanMinus - cpanm client
46  
47 =head1 DESCRIPTION
48  
49 This plugin enables users to curate L<local::lib> as set up in
50 L<Devel::IPerl::Plugin::Perlbrew>.
51  
52 Once users have access to L<Devel::IPerl::Plugin::Perlbrew> they wish to have
53 the ability to curate the libraries they
54 L<create|Devel::IPerl::Plugin::Perlbrew#perlbrew_lib_create>. While this is easy
55 to achieve at the command line, the notebook is an excellent place to document
56 this workflow as well.
57  
58 =head1 SYNOPSIS
59  
60 IPerl->load_plugin('CpanMinus') unless IPerl->can('cpanm');
61 # create and use a library
62 IPerl->perlbrew_lib_create('cpanm-test');
63 IPerl->perlbrew('cpanm-test');
64 # install dependencies for notebook
65 IPerl->cpanm_installdeps('.');
66 # install a specific module
67 IPerl->cpanm('Test::Pod');
68  
69 =head1 IPerl Interface Method
70  
71 =head2 register
72  
73 Called by C<<< IPerl->load_plugin('CpanMinus') >>>.
74  
75 =head1 REGISTERED METHODS
76  
77 These all take as arguments any arguments that are accepted by the command line
78 client L<cpanm>.
79  
80 =head2 cpanm
81  
82 # install a specific module
83 IPerl->cpanm('Test::Pod');
84  
85 Use L<cpanm> to install the given module.
86  
87 =head2 cpanm_info
88  
89 IPerl->cpanm_info('Test::Pod');
90  
91 Displays the distribution information in "AUTHOR/Dist-Name-ver.tar.gz" format.
92  
93 =head2 cpanm_installdeps
94  
95 # install dependencies as listed in cpanfile in current directory
96 IPerl->cpanm_installdeps('.');
97 # install dependencies for a module
98 IPerl->cpanm_installdeps('-n', '--quiet', 'Test::Pod');
99  
100 =cut