blib/lib/Dist/Zilla/Chrome/Test.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 83.3% 5 / 6 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 3 totaltotal 89.6% 52 / 58 CC 5 SCAR 8.8
CC
5
Cov
95%
prompt_str
5.0
prompt_any_key
2.0
BEGIN
1.0
CRAP 2.4
« blib/lib/Dist/Zilla/Plugin/ModuleShareDirs.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/InlineFiles.pm »
1 package Dist::Zilla::Chrome::Test 6.040;
2 # ABSTRACT: the chrome used by Dist::Zilla::Tester
3  
4 50 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 50 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 50 ▶use MooseX::Types::Moose qw(ArrayRef HashRef Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 50 ▶use Dist::Zilla::Types qw(OneZero);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 50 ▶use Log::Dispatchouli 1.102220;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 50 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 has logger => (
15 is => 'ro',
16 178 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 178 Log::Dispatchouli->new({
18 ident => 'Dist::Zilla::Tester',
19 log_pid => 0,
20 to_self => 1,
21 });
22 }
23 50 );
24  
25 #pod =attr response_for
26 #pod
27 #pod The response_for attribute (which exists only in the Test chrome) is a
28 #pod hashref that lets you specify the answer to questions asked by
29 #pod C<prompt_str> or C<prompt_yn>. The key is the prompt string. If the
30 #pod value is a string, it is returned every time that question is asked.
31 #pod If the value is an arrayref, the first element is shifted off and
32 #pod returned every time the question is asked. If the arrayref is empty
33 #pod (or the prompt is not listed in the hash), the default answer (if any)
34 #pod is returned.
35 #pod
36 #pod Since you can't pass arguments to the Chrome constructor, response_for
37 #pod is initialized to an empty hash, and you can add entries after
38 #pod construction with the C<set_response_for> method:
39 #pod
40 #pod $chrome->set_response_for($prompt => $response);
41 #pod
42 #pod =cut
43  
44 has response_for => (
45 isa => HashRef[ ArrayRef | Str ],
46 traits => [ 'Hash' ],
47 178 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
48 50 handles => {
49 response_for => 'get',
50 set_response_for => 'set',
51 },
52 );
53  
54 15 ▶sub prompt_str {
Subroutine prompt_str: called CC=5 SCAR=16.1
Pod undocumented
55 15 my ($self, $prompt, $arg) = @_;
56 15 ▶ $arg ||= {};
Condition100%2/2
$arg ||= {}
l!l
123
MC/DC100%1/1
$arg ||= {}
$arg
Truth table100%2/2
A
A= $arg
Aresult
11
00
57  
58 15 my $response = $self->response_for($prompt);
59  
60 15 ▶ $response = shift @$response if ref $response;
Branch: 1 branch
BranchTrueFalseTotal
if ref $response 0 15 15
61  
62 15 ▶ $response = $arg->{default} unless defined $response;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $response 6 9 15
63  
64 15 ▶ $self->logger->log_fatal("no response for test prompt '$prompt'")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $response 1 14 15
65 unless defined $response;
66  
67 14 return $response;
68 }
69  
70 9 ▶sub prompt_yn {
Subroutine prompt_yn: called CC=1 SCAR=0.0
Pod undocumented
71 9 my $self = shift;
72  
73 9 return OneZero->coerce( $self->prompt_str(@_) );
74 }
75  
76 0 ▶sub prompt_any_key { return }
Subroutine prompt_any_key: not called CC=1 SCAR=6.9
Pod undocumented
77  
78 50 with 'Dist::Zilla::Role::Chrome';
79 50 __PACKAGE__->meta->make_immutable;
80 50 1;
81  
82 __END__
« blib/lib/Dist/Zilla/Plugin/ModuleShareDirs.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/InlineFiles.pm »