Client/Command.pm

filter: Statementstmt 85.7% 12 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 89.4% 17 / 19 CC 1 SCAR 0.6
CC
1
Cov
86%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Client/API.pm ↑ Summary Client.pm »
1 package CPAN::Mini::Inject::REST::Client::Command;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use App::Cmd::Setup -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 0 ▶use CPAN::Mini::Inject::REST::Client::API;
Subroutine BEGIN: called CC=1 SCAR=2.6
8  
9  
10 #--Define default options for all commands--------------------------------------
11  
12 sub opt_spec {
13 my ( $class, $app ) = @_;
14 return (
15 [ 'protocol=s' => "Network protocol ('http' or 'https')", {default => $app->config->{protocol} || 'http'} ],
16 [ 'host=s' => "Hostname of your CPAN server", {default => $app->config->{host} || '127.0.0.1'} ],
17 [ 'port=i' => "CPAN server port number", {default => $app->config->{port} || '80'} ],
18 [ 'username=s' => "Username (if using HTTP basic auth)", {default => $app->config->{username} || undef} ],
19 [ 'password=s' => "Password (if using HTTP basic auth)", {default => $app->config->{password} || undef} ],
20 $class->options($app),
21 );
22 }
23  
24  
25 #--Build the API object---------------------------------------------------------
26  
27 sub api {
28 my ($self, $opt) = @_;
29
30 my $api_options = {
31 protocol => $opt->{protocol},
32 host => $opt->{host},
33 port => $opt->{port},
34 };
35
36 $opt->{username} && do {$api_options->{username} = $opt->{username}};
37 $opt->{password} && do {$api_options->{password} = $opt->{password}};
38
39 return CPAN::Mini::Inject::REST::Client::API->new($api_options);
40 }
41  
42  
43 #-------------------------------------------------------------------------------
44  
45 1;
« Client/API.pm ↑ Summary Client.pm »