blib/lib/Test/Smoke/App/ConfigSmoke/Smokedir.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 56 CC 2 SCAR 10.6
CC
2
Cov
0%
check_smokedir
6.0
config_smokedir
2.0
use_smokedir_option
2.0
CRAP 2.9
1 package Test::Smoke::App::ConfigSmoke::Smokedir;
2 use warnings;
3 use strict;
4  
5 our $VERSION = '0.001';
6  
7 use Exporter 'import';
8 our @EXPORT = qw/ config_smokedir check_smokedir /;
9  
10 use Test::Smoke::App::AppOption;
11 use Test::Smoke::App::Options;
12  
13 =head1 NAME
14  
15 Test::Smoke::App::ConfigSmoke::Smokedir - Mixin for Test::Smoke::App::ConfigSmoke.
16  
17 =head1 DESCRIPTION
18  
19 These methods will be added to the L<Test::Smoke::App::ConfigSmoke> class.
20  
21 =head2 config_smokedir
22  
23 Configure options: C<ddir>
24  
25 =cut
26  
27 sub config_smokedir {
28 my $self = shift;
29  
30 print "\n-- Smoke working directory section --\n";
31 my $use_dir = 0;
32 do {
33 $self->handle_option( Test::Smoke::App::Options->ddir() );
34 $use_dir = $self->check_smokedir;
35 } until $use_dir;
36 delete($self->current_values->{use_smokedir});
37 }
38  
39 =head2 check_smokedir
40  
41 Will check if an existing dir already has a perl source tree.
42  
43 =cut
44  
45 sub check_smokedir {
46 my $self = shift;
47  
48 my @makes_perl_dist = qw(Artistic perl.c perl.h .patch);
49 my $looks_like_perl = 1;
50 for my $file (@makes_perl_dist) {
51 my $fn = File::Spec->catfile( $self->current_values->{ddir}, $file);
52 $looks_like_perl &&= -f $fn;
53 }
54 if ($looks_like_perl) {
55 printf "[%s]\n", $self->current_values->{ddir};
56 return $self->handle_option(use_smokedir_option())
57 }
58 return 1;
59 }
60  
61 =head2 use_smokedir_option
62  
63 This option C<use_smokedir> will not be in the config-file. We use it for the
64 flow of the configuration, to see if an existing source-directory should be
65 (re)used.
66  
67 =cut
68  
69 sub use_smokedir_option {
70 return Test::Smoke::App::AppOption->new(
71 name => 'use_smokedir',
72 default => 1,
73 helptext => "Smoke working directory already contains a perl source",
74 configtext => "!! Would you still like to this directory?",
75 configtype => 'prompt_yn',
76 configalt => sub { [qw/ Y n /] },
77 configdft => sub {'y'},
78 );
79 }
80  
81 1;
82  
83 =head1 COPYRIGHT
84  
85 (c) 2020, All rights reserved.
86  
87 * Abe Timmerman <abeltje@cpan.org>
88  
89 This library is free software; you can redistribute it and/or modify
90 it under the same terms as Perl itself.
91  
92 See:
93  
94 =over 4
95  
96 =item * L<http://www.perl.com/perl/misc/Artistic.html>
97  
98 =item * L<http://www.gnu.org/copyleft/gpl.html>
99  
100 =back
101  
102 This program is distributed in the hope that it will be useful,
103 but WITHOUT ANY WARRANTY; without even the implied warranty of
104 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
105  
106 =cut