summaryrefslogtreecommitdiff
path: root/author/extract-inline-tests
blob: aa907877d428ac27bc0d175c26293af38b384a35 (plain)
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
#!/usr/bin/perl

use strict;
use warnings;

use File::Find::Rule;
use Getopt::Long;
use Test::Inline;

use lib 'inc';
use MyInline;

my $quiet;
GetOptions( 'quiet' => \$quiet );

my $inline = Test::Inline->new(
    verbose        => !$quiet,
    ExtractHandler => 'My::Extract',
    ContentHandler => 'My::Content',
    OutputHandler  => 'My::Output',
);

for my $pod (
    File::Find::Rule->file->name(qr/\.pod$/)->in('lib/Moose/Cookbook') ) {
    $inline->add($pod);
}

$inline->save;

{

    package My::Output;

    use Path::Tiny;

    sub write {
        my $class   = shift;
        my $name    = shift;
        my $content = shift;

        $name =~ s/^moose_cookbook_//;

        path( "t/recipes/$name" )->spew( $content );

        return 1;
    }
}