File Coverage

lib/Dist/Zilla/App/Command/configure_CSJEWELL.pm
Criterion Covered Total %
statement 20 43 46.5
branch 0 8 0.0
condition 0 3 0.0
subroutine 7 12 58.3
pod 3 3 100.0
total 30 69 43.4


line stmt bran cond sub pod time code
1             package Dist::Zilla::App::Command::configure_CSJEWELL;
2              
3 1     1   1594 use 5.008003;
  1         4  
4 1     1   6 use strict;
  1         3  
  1         29  
5 1     1   6 use warnings;
  1         3  
  1         37  
6 1     1   591 use autodie;
  1         15770  
  1         7  
7              
8 1     1   8418 use Dist::Zilla::App -command;
  1         35768  
  1         13  
9 1     1   23858 use Dist::Zilla::Util;
  1         20171  
  1         48  
10 1     1   33 use File::Spec;
  1         2  
  1         470  
11              
12             our $VERSION = '0.994';
13              
14             sub abstract { ## no critic(ProhibitAmbiguousNames)
15 0     0 1   return q{configure the 'CSJEWELL' minting profile.};
16             }
17              
18             sub validate_args {
19 0     0 1   my ($self, undef, $args) = @_;
20              
21 0 0         if (0 != @{$args}) {
  0            
22 0           $self->usage_error('Too many arguments');
23             }
24              
25 0           return;
26             }
27              
28             sub execute {
29 0     0 1   my ($self, undef, undef) = @_;
30              
31 0           my $chrome = $self->app()->chrome();
32              
33             ## no critic(ProtectPrivateSubs)
34 0           my $config_root = Dist::Zilla::Util->_global_config_root();
35              
36 0 0 0       if ( not -d $config_root
37             or not -f $config_root->child('config.ini'))
38             {
39 0           $chrome->logger()->log_fatal([ 'A per-user configuration file does not exist in %s', "$config_root", ]);
40              
41 0           return;
42             }
43              
44             my $homepage = $chrome->prompt_str(
45             'Where is your homepage?',
46 0 0   0     { check => sub { defined $_[0] and $_[0] =~ /\S/ms },
47 0           default => 'https://metacpan.org/author/USERNAME/',
48             },
49             );
50              
51             my $repo = $chrome->prompt_str(
52             'Where are your repositories?',
53 0 0   0     { check => sub { defined $_[0] and $_[0] =~ /\S/ms },
54 0           default => 'https://github.com/username/',
55             },
56             );
57              
58 0           open my $fh, '>>', $config_root->child('config.ini');
59              
60 0           $fh->print("\n[%DefaultURLs]\n");
61 0           $fh->print("homepage = $homepage\n");
62 0           $fh->print("repository_location = $repo\n\n");
63              
64 0           close $fh;
65              
66 0           $self->log('Added to config.ini file.');
67              
68 0           return;
69             } ## end sub execute
70              
71             1;
72              
73             __END__
74              
75             =pod
76              
77             =head1 NAME
78              
79             Dist::Zilla::App::Command::configure_CSJEWELL - set up the global config file
80              
81             =head1 VERSION
82              
83             This document describes Dist::Zilla::App::Command::configure_CSJEWELL version 0.994.
84              
85             =head1 SYNOPSIS
86              
87             C:\> dzil configure_CSJEWELL
88              
89             This command prompts the user for information that is used in the CSJEWELL
90             minting profile and stores it in F<config.ini>.
91              
92             =for Pod::Coverage abstract validate_args execute
93              
94             =head1 AUTHOR
95              
96             Curtis Jewell <CSJewell@cpan.org>
97              
98             =head1 SEE ALSO
99              
100             L<Dist::Zilla::BeLike::CSJEWELL|Dist::Zilla::BeLike::CSJEWELL>
101              
102             =head1 LICENSE AND COPYRIGHT
103              
104             Copyright (c) 2010, 2021 Curtis Jewell C<< CSJewell@cpan.org >>.
105              
106             This module is free software; you can redistribute it and/or
107             modify it under the same terms as Perl itself, either version
108             5.8.1 or any later version. See L<perlartistic|perlartistic>
109             and L<perlgpl|perlgpl>.
110              
111             The full text of the license can be found in the
112             LICENSE file included with this module.
113              
114             =head1 DISCLAIMER OF WARRANTY
115              
116             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
117             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
118             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
119             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
120             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
121             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
122             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
123             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
124             NECESSARY SERVICING, REPAIR, OR CORRECTION.
125              
126             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
127             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
128             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
129             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
130             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
131             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
132             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
133             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
134             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
135             SUCH DAMAGES.
136              
137             =cut