Inkt/Role/WriteINSTALL.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 54 CC 1 SCAR 6.9
CC
1
Cov
0%
Build_INSTALL
2.0
installfile_summary
2.0
installfile_cpanm
2.0
CRAP 2.0
1 package Dist::Inkt::Role::WriteINSTALL;
2  
3 our $AUTHORITY = 'cpan:TOBYINK';
4 our $VERSION = '0.026';
5  
6 use Moose::Role;
7 use namespace::autoclean;
8  
9 after BUILD => sub {
10 my $self = shift;
11 unshift @{ $self->targets }, 'INSTALL';
12 };
13  
14 sub Build_INSTALL
15 {
16 my $self = shift;
17 my $file = $self->targetfile('INSTALL');
18 $file->exists and return $self->log('Skipping %s; it already exists', $file);
19 $self->log('Writing %s', $file);
20
21 my $pod = 'Pod::Text'->new(
22 sentance => 0,
23 width => 78,
24 errors => 'die',
25 quotes => q[``],
26 utf8 => 1,
27 );
28 $pod->output_fh($file->openw_utf8);
29 $pod->parse_string_document(
30 join(
31 "\n\n",
32 "=pod",
33 "=encoding utf-8",
34 $self->installfile_summary,
35 $self->installfile_cpanm,
36 $self->installfile_cpan,
37 $self->installfile_manual,
38 $self->installfile_features,
39 "=cut",
40 "",
41 )
42 );
43 }
44  
45 sub installfile_summary
46 {
47 my $self = shift;
48 return sprintf("Installing %s should be straightforward.\n\n", $self->name);
49 }
50  
51 sub installfile_cpanm
52 {
53 my $self = shift;
54 return (
55 "=head1 INSTALLATION WITH CPANMINUS",
56 "If you have cpanm, you only need one line:",
57 sprintf("\t%% cpanm %s", $self->lead_module),
58 "If you are installing into a system-wide directory, you may need to pass the \"-S\" flag to cpanm, which uses sudo to install the module:",
59 sprintf("\t%% cpanm -S %s", $self->lead_module),
60 );
61 }
62  
63 sub installfile_cpan
64 {
65 my $self = shift;
66 return (
67 "=head1 INSTALLATION WITH THE CPAN SHELL",
68 "Alternatively, if your CPAN shell is set up, you should just be able to do:",
69 sprintf("\t%% cpan %s", $self->lead_module),
70 );
71 }
72  
73 sub installfile_manual
74 {
75 my $self = shift;
76 return (
77 "=head1 MANUAL INSTALLATION",
78 "As a last resort, you can manually install it. Download the tarball and unpack it.",
79 "Consult the file META.json for a list of pre-requisites. Install these first.",
80 sprintf("To build %s:", $self->name),
81 "\t% perl Makefile.PL\n".
82 "\t% make && make test",
83 "Then install it:",
84 "\t% make install",
85 "If you are installing into a system-wide directory, you may need to run:",
86 "\t% sudo make install",
87 );
88 }
89  
90 sub installfile_features
91 {
92 my $self = shift;
93 my @features = sort keys %{$self->metadata->{optional_features}}
94 or return;
95
96 return (
97 "=head1 OPTIONAL FEATURES",
98 sprintf("%s provides several optional features, which may require additional pre-requisites. These features are:", $self->name),
99 "=over",
100 map(
101 sprintf(
102 "=item *\n\n%s (%s)",
103 $_,
104 $self->metadata->{optional_features}{$_}{description} || 'no description'
105 ),
106 @features
107 ),
108 "=back",
109 "cpanminus 1.7000 and above support installing optional features:",
110 sprintf("\t%% cpanm --with-feature=%s %s", $features[0], $self->lead_module),
111 "Otherwise, Makefile.PL can prompt you to select features. Set the C<MM_INSTALL_FEATURES> environment variable to \"1\" before running Makefile.PL.",
112 );
113 }
114  
115 1;