line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Chrome::Test 6.030; |
2
|
|
|
|
|
|
|
# ABSTRACT: the chrome used by Dist::Zilla::Tester |
3
|
|
|
|
|
|
|
|
4
|
49
|
|
|
49
|
|
420
|
use Moose; |
|
49
|
|
|
|
|
121
|
|
|
49
|
|
|
|
|
407
|
|
5
|
|
|
|
|
|
|
|
6
|
49
|
|
|
49
|
|
355456
|
use Dist::Zilla::Pragmas; |
|
49
|
|
|
|
|
146
|
|
|
49
|
|
|
|
|
393
|
|
7
|
|
|
|
|
|
|
|
8
|
49
|
|
|
49
|
|
22195
|
use MooseX::Types::Moose qw(ArrayRef HashRef Str); |
|
49
|
|
|
|
|
2390552
|
|
|
49
|
|
|
|
|
547
|
|
9
|
49
|
|
|
49
|
|
300488
|
use Dist::Zilla::Types qw(OneZero); |
|
49
|
|
|
|
|
216
|
|
|
49
|
|
|
|
|
641
|
|
10
|
49
|
|
|
49
|
|
156213
|
use Log::Dispatchouli 1.102220; |
|
49
|
|
|
|
|
11475550
|
|
|
49
|
|
|
|
|
1992
|
|
11
|
|
|
|
|
|
|
|
12
|
49
|
|
|
49
|
|
530
|
use namespace::autoclean; |
|
49
|
|
|
|
|
173
|
|
|
49
|
|
|
|
|
560
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has logger => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
default => sub { |
17
|
|
|
|
|
|
|
Log::Dispatchouli->new({ |
18
|
|
|
|
|
|
|
ident => 'Dist::Zilla::Tester', |
19
|
|
|
|
|
|
|
log_pid => 0, |
20
|
|
|
|
|
|
|
to_self => 1, |
21
|
|
|
|
|
|
|
}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
); |
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
|
|
|
|
|
|
|
default => sub { {} }, |
48
|
|
|
|
|
|
|
handles => { |
49
|
|
|
|
|
|
|
response_for => 'get', |
50
|
|
|
|
|
|
|
set_response_for => 'set', |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub prompt_str { |
55
|
15
|
|
|
15
|
0
|
3806
|
my ($self, $prompt, $arg) = @_; |
56
|
15
|
|
100
|
|
|
143
|
$arg ||= {}; |
57
|
|
|
|
|
|
|
|
58
|
15
|
|
|
|
|
835
|
my $response = $self->response_for($prompt); |
59
|
|
|
|
|
|
|
|
60
|
15
|
50
|
|
|
|
88
|
$response = shift @$response if ref $response; |
61
|
|
|
|
|
|
|
|
62
|
15
|
100
|
|
|
|
98
|
$response = $arg->{default} unless defined $response; |
63
|
|
|
|
|
|
|
|
64
|
15
|
100
|
|
|
|
166
|
$self->logger->log_fatal("no response for test prompt '$prompt'") |
65
|
|
|
|
|
|
|
unless defined $response; |
66
|
|
|
|
|
|
|
|
67
|
14
|
|
|
|
|
333
|
return $response; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub prompt_yn { |
71
|
9
|
|
|
9
|
0
|
39
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
9
|
|
|
|
|
170
|
return OneZero->coerce( $self->prompt_str(@_) ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
0
|
|
sub prompt_any_key { return } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Chrome'; |
79
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=encoding UTF-8 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Dist::Zilla::Chrome::Test - the chrome used by Dist::Zilla::Tester |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 VERSION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
version 6.030 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 PERL VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
99
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
100
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
101
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
104
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
105
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
106
|
|
|
|
|
|
|
the minimum required perl. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 response_for |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
The response_for attribute (which exists only in the Test chrome) is a |
113
|
|
|
|
|
|
|
hashref that lets you specify the answer to questions asked by |
114
|
|
|
|
|
|
|
C<prompt_str> or C<prompt_yn>. The key is the prompt string. If the |
115
|
|
|
|
|
|
|
value is a string, it is returned every time that question is asked. |
116
|
|
|
|
|
|
|
If the value is an arrayref, the first element is shifted off and |
117
|
|
|
|
|
|
|
returned every time the question is asked. If the arrayref is empty |
118
|
|
|
|
|
|
|
(or the prompt is not listed in the hash), the default answer (if any) |
119
|
|
|
|
|
|
|
is returned. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Since you can't pass arguments to the Chrome constructor, response_for |
122
|
|
|
|
|
|
|
is initialized to an empty hash, and you can add entries after |
123
|
|
|
|
|
|
|
construction with the C<set_response_for> method: |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$chrome->set_response_for($prompt => $response); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Ricardo SIGNES. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
136
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |