blib/lib/App/Pinto.pm

filter: Statementstmt 42.5% 17 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 55.5% 5 / 9 Podpod 33.3% 1 / 3 totaltotal 26.1% 23 / 88 CC 11 SCAR 40.8
CC
11
Cov
26%
pinto
110.0
pinto_class_for
6.0
global_opt_spec
2.0
CRAP 59.0
« blib/lib/Pinto/Editor/Edit.pm ↑ Summary blib/lib/Pinto/Editor/Clip.pm »
1 # ABSTRACT: Command-line driver for Pinto
2  
3 package App::Pinto;
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Class::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use App::Cmd::Setup -app;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Pinto::Util qw(is_remote_repo);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #------------------------------------------------------------------------------
13  
14 1 our $VERSION = '0.14'; # VERSION
15  
16 #------------------------------------------------------------------------------
17  
18 0 ▶sub global_opt_spec {
Subroutine global_opt_spec: not called CC=1 SCAR=6.9
Pod documented
19  
20 return (
21 0 [ 'root|r=s' => 'Path to your repository root directory' ],
22 [ 'color|colour!' => 'Colorize any output (negatable)' ],
23 [ 'password|p=s' => 'Password for server authentication' ],
24 [ 'quiet|q' => 'Only report fatal errors' ],
25 [ 'username|u=s' => 'Username for server authentication' ],
26 [ 'verbose|v+' => 'More diagnostic output (repeatable)' ],
27 );
28 }
29  
30 #------------------------------------------------------------------------------
31  
32 0 ▶sub pinto {
Subroutine pinto: not called CC=10 SCAR=47.0
Pod undocumented
33 0 my ($self) = @_;
34  
35 0 ▶ return $self->{pinto} ||= do {
Condition0%0/3
$self->{"pinto"} ||= do { my $global_options = $self->global_options; $global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root"); delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"}); $global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}; $global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-"; my $pinto_class = $self->pinto_class_for($global_options->{"root"}); Class::Load::load_class($pinto_class); $pinto_class->new(%{$global_options;}) }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"pinto"} ||= do { my $global_options = $self->global_options; $global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root"); delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"}); $global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}; $global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-"; my $pinto_class = $self->pinto_class_for($global_options->{"root"}); Class::Load::load_class($pinto_class); $pinto_class->new(%{$global_options;}) }
$self->{"pinto"} do { my $global_options = $self->global_options; $global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root"); delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"}); $global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}; $global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-"; my $pinto_class = $self->pinto_class_for($global_options->{"root"}); Class::Load::load_class($pinto_class); $pinto_class->new(%{$global_options;}) }
Truth table0%0/3
A ||= B
A= $self->{"pinto"}B= do { my $global_options = $self->global_options; $global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root"); delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"}); $global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}; $global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-"; my $pinto_class = $self->pinto_class_for($global_options->{"root"}); Class::Load::load_class($pinto_class); $pinto_class->new(%{$global_options;}) }
ABresult
1X1
011
000
36 0 my $global_options = $self->global_options;
37  
38 $global_options->{root} ||= $ENV{PINTO_REPOSITORY_ROOT}
39 0 ▶ || $self->usage_error('Must specify a repository root');
Condition0%0/6
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root")
l!l&&r!l&&!r
000
$ENV{'PINTO_REPOSITORY_ROOT'} || $self->usage_error('Must specify a repository root')
l!l&&r!l&&!r
000
MC/DC0%0/3
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root")
$global_options->{"root"} $ENV{'PINTO_REPOSITORY_ROOT'} $self->usage_error('Must specify a repository root')
Truth table0%0/4
A ||= B || C
A= $global_options->{"root"}B= $ENV{'PINTO_REPOSITORY_ROOT'}C= $self->usage_error('Must specify a repository root')
ABCresult
1XX1
01X1
0011
0000
40  
41 # Discard password and username arguments if this is not a
42 # remote repository. StrictConstrutor will not allow them.
43 0 delete @{$global_options}{qw(username password)}
44 0 ▶ if not is_remote_repo($global_options->{root});
Branch: 1 branch
BranchTrueFalseTotal
unless is_remote_repo($global_options->{"root"}) 0 0 0
45  
46 # Disable color if STDOUT is not a tty, unless it has already been
47 # explicitly enabled. For example: pinto --color ls | less -R
48 $global_options->{color} = 0 if ($ENV{PINTO_NO_COLOR} or not -t STDOUT)
49 0 ▶ and not defined $global_options->{color};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"} 0 0 0
Condition0%0/6
$ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}
!ll&&!rl&&r
000
$ENV{"PINTO_NO_COLOR"} or not -t STDOUT
l!l&&r!l&&!r
000
MC/DC0%0/3
$ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}
$ENV{"PINTO_NO_COLOR"} not -t STDOUT not defined $global_options->{"color"}
Truth table0%0/5
A or not(B) and not(C)
A= $ENV{"PINTO_NO_COLOR"}B= not -t STDOUTC= not defined $global_options->{"color"}
ABCresult
00X0
1X00
0100
1X11
0111
50  
51 $global_options->{password} = $self->_prompt_for_password
52 0 ▶ if defined $global_options->{password} and $global_options->{password} eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if defined $global_options->{"password"} and $global_options->{"password"} eq "-" 0 0 0
Condition0%0/3
defined $global_options->{"password"} and $global_options->{"password"} eq "-"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $global_options->{"password"} and $global_options->{"password"} eq "-"
defined $global_options->{"password"} $global_options->{"password"} eq "-"
Truth table0%0/3
A and B
A= defined $global_options->{"password"}B= $global_options->{"password"} eq "-"
ABresult
0X0
100
111
53  
54 0 my $pinto_class = $self->pinto_class_for( $global_options->{root} );
55 0 Class::Load::load_class($pinto_class);
56  
57 0 $pinto_class->new( %{$global_options} );
58 };
59 }
60  
61 #------------------------------------------------------------------------------
62  
63 0 ▶sub pinto_class_for {
Subroutine pinto_class_for: not called CC=2 SCAR=17.9
Pod undocumented
64 0 my ( $self, $root ) = @_;
65 0 ▶ return is_remote_repo($root) ? 'Pinto::Remote' : 'Pinto';
Branch: 1 branch
BranchTrueFalseTotal
is_remote_repo($root) ? : 0 0 0
66 }
67  
68 #------------------------------------------------------------------------------
69  
70 0 ▶sub _prompt_for_password {
Subroutine _prompt_for_password: not called CC=1 SCAR=6.9
71 0 my ($self) = @_;
72  
73 0 require Encode;
74 0 require IO::Prompt;
75  
76 0 my $repo = $self->global_options->{root};
77 0 my $prompt = "Password for repository at $repo: ";
78 0 my $input = IO::Prompt::prompt( $prompt, -echo => '*', -tty );
79 0 my $password = Encode::decode_utf8($input);
80  
81 0 return $password;
82 }
83  
84 #-------------------------------------------------------------------------------
85  
86 1 1;
87  
88 __END__
« blib/lib/Pinto/Editor/Edit.pm ↑ Summary blib/lib/Pinto/Editor/Clip.pm »