File: andoc.pm

package info (click to toggle)
libpandoc-wrapper-perl 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: perl: 589; makefile: 5; sh: 1
file content (58 lines) | stat: -rw-r--r-- 1,270 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package App::Prove::Plugin::andoc;
use 5.014;
use warnings;

our $VERSION = '0.9.2';

use Pandoc;
use File::Temp qw(tempdir);
use Cwd qw(realpath);

sub load {
    my ( $class, $p ) = @_;
    my ($bin) = @{ $p->{args} };

    die "Usage: prove -Pandoc=EXECUTABLE ...\n" unless defined $bin;
    die "Pandoc executable not found: $bin\n"   unless -x $bin;

    # dies if executable is not pandoc
    my $pandoc = Pandoc->new($bin);

    my $tmp = tempdir( CLEANUP => 1 );
    symlink( realpath( $pandoc->bin ), "$tmp/pandoc" )
      or die "symlinking pandoc failed!\n";

    $ENV{PATH} = "$tmp:" . $ENV{PATH};

    if ( $p->{app_prove}->{verbose} ) {
        print "# pandoc executable set to $bin\n";
    }
}

1;

__END__

=head1 NAME

App::Prove::Plugin::andoc - Select pandoc executable for tests

=head1 SYNOPSIS

  # specify executable
  prove -Pandoc=bin/pandoc-2.1.2 ...

  # specify executable in ~/.pandoc/bin by version
  prove -Pandoc=2.1.2 ...

=head1 DESCRIPTION

This plugin to L<prove> modifies PATH to use a selected pandoc executable
before running tests. See L<Pandoc::Release> to download pandoc executables.

=head1 SEE ALSO

Pandoc executable with package L<Pandoc> can be specified by constructor or
with environment variable C<PANDOC_PATH>.

=cut