2 package Module::Install::ReadmeFromPod;
7 use base qw(Module::Install::Base);
14 return unless $self->is_admin;
17 my $in_file = shift || $self->_all_from
18 or die "Can't determine file to make readme_from";
20 # Get optional arguments
21 my ($clean, $format, $out_file, $options);
24 # Arguments are in a hashref
25 if ( ref($args) ne 'HASH' ) {
26 die "Expected a hashref but got a ".ref($args)."\n";
28 $clean = $args->{'clean'};
29 $format = $args->{'format'};
30 $out_file = $args->{'output_file'};
31 $options = $args->{'options'};
34 # Arguments are in a list
46 print "readme_from $in_file to $format\n";
47 if ($format =~ m/te?xt/) {
48 $out_file = $self->_readme_txt($in_file, $out_file, $options);
49 } elsif ($format =~ m/html?/) {
50 $out_file = $self->_readme_htm($in_file, $out_file, $options);
51 } elsif ($format eq 'man') {
52 $out_file = $self->_readme_man($in_file, $out_file, $options);
53 } elsif ($format eq 'pdf') {
54 $out_file = $self->_readme_pdf($in_file, $out_file, $options);
58 $self->clean_files($out_file);
66 my ($self, $in_file, $out_file, $options) = @_;
67 $out_file ||= 'README';
69 my $parser = Pod::Text->new( @$options );
70 open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n";
71 $parser->output_fh( *$out_fh );
72 $parser->parse_file( $in_file );
79 my ($self, $in_file, $out_file, $options) = @_;
80 $out_file ||= 'README.htm';
84 "--outfile=$out_file",
87 # Remove temporary files if needed
88 for my $file ('pod2htmd.tmp', 'pod2htmi.tmp') {
90 unlink $file or warn "Warning: Could not remove file '$file'.\n$!\n";
98 my ($self, $in_file, $out_file, $options) = @_;
99 $out_file ||= 'README.1';
101 my $parser = Pod::Man->new( @$options );
102 $parser->parse_from_file($in_file, $out_file);
108 my ($self, $in_file, $out_file, $options) = @_;
109 $out_file ||= 'README.pdf';
110 eval { require App::pod2pdf; }
111 or die "Could not generate $out_file because pod2pdf could not be found\n";
112 my $parser = App::pod2pdf->new( @$options );
113 $parser->parse_from_file($in_file);
114 open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n";
125 return unless $self->admin->{extensions};
126 my ($metadata) = grep {
127 ref($_) eq 'Module::Install::Metadata';
128 } @{$self->admin->{extensions}};
129 return unless $metadata;
130 return $metadata->{values}{all_from} || '';