@@ -5,14 +5,12 @@ use Moose;
55
66use namespace::autoclean;
77
8- with ' Dist::Zilla::Role::FileGatherer' , ' Dist::Zilla::Role::TextTemplate' ;
9-
10- my $content = <<'EOF' ;
11- # Installing File-LibMagic
8+ extends ' Dist::Zilla::Plugin::InstallGuide' ;
129
10+ my $requires_libmagic = <<'EOF' ;
1311Installing File-LibMagic requires that you have the *libmagic.so* library and
1412the *magic.h* header file installed. Once those are installed, this module is
15- installed like any other Perl distributions .
13+ installed like any other Perl distribution .
1614
1715## Installing libmagic
1816
@@ -23,70 +21,34 @@ On Debian/Ubuntu run:
2321On Mac you can use homebrew (https://brew.sh/):
2422
2523 brew install libmagic
24+ EOF
2625
27- ## Installation with cpanm
28-
29- If you have cpanm, you only need one line:
30-
31- % cpanm File::LibMagic
32-
33- If you are installing into a system-wide directory, you may need to pass the
34- "-S" flag to cpanm, which uses sudo to install the module:
35-
36- % cpanm -S File::LibMagic
37-
38- ## Installing with the CPAN shell
39-
40- Alternatively, if your CPAN shell is set up, you should just be able to do:
41-
42- % cpan File::LibMagic
43-
44- ## Manual installation
45-
46- As a last resort, you can manually install it. Download the tarball, untar it,
47- then build it:
48-
49- % perl Makefile.PL
50- % make && make test
51-
52- Then install it:
53-
54- % make install
55-
56- If you are installing into a system-wide directory, you may need to run:
57-
58- % sudo make install
59-
26+ my $specifying = <<'EOF' ;
6027## Specifying additional lib and include directories
6128
6229On some systems, you may need to pass additional lib and include directories
6330to the Makefile.PL. You can do this with the `--lib` and `--include`
6431parameters:
6532
66- perl Makefile.PL --lib /usr/local/include --include /usr/local/include
33+ perl Makefile.PL --lib /usr/local/lib --include /usr/local/include
6734
6835You can pass these parameters multiple times to specify more than one
6936location.
70-
71- ## Documentation
72-
73- File-LibMagic documentation is available as POD.
74- You can run perldoc from a shell to read the documentation:
75-
76- % perldoc File::LibMagic
7737EOF
7838
79- sub gather_files {
39+ sub template {
8040 my $self = shift ;
8141
82- $self -> add_file(
83- Dist::Zilla::File::FromCode-> new(
84- name => ' INSTALL.md' ,
85- code => sub {$content },
86- )
87- );
42+ my $template = $self -> SUPER::template;
43+ $template
44+ =~ s { Installing \{\{ .+ \}\} is straightforward\.\n } { $requires_libmagic }
45+ or die
46+ q{ Could not add the "requires libmagic" text to the install guide} ;
47+ $template =~ s { (## Manual installation)} { $specifying \n $1 }
48+ or die
49+ q{ Could not add the "specifying libmagic location" text to the install guide} ;
8850
89- return ;
51+ return $template ;
9052}
9153
9254__PACKAGE__ -> meta()-> make_immutable();
0 commit comments