A mutable class will throw errors from inside CMOP, and that's expected
[gitmo/Moose.git] / inc / ExtractInlineTests.pm
CommitLineData
4dc2cd56 1package inc::ExtractInlineTests;
e4d40db1 2
3use Moose;
4
5with 'Dist::Zilla::Role::FileGatherer';
6
7use File::Basename qw( basename );
8use File::Find::Rule;
9use File::Spec;
10use File::Temp qw( tempdir );
d62bc8fd 11use inc::MyInline;
e4d40db1 12use Test::Inline;
13
14sub gather_files {
15 my $self = shift;
16 my $arg = shift;
17
18 my $inline = Test::Inline->new(
19 verbose => 0,
20 ExtractHandler => 'My::Extract',
21 ContentHandler => 'My::Content',
22 OutputHandler => My::Output->new($self),
23 );
24
25 for my $pod (
26 File::Find::Rule->file->name(qr/\.pod$/)->in('lib/Moose/Cookbook') ) {
27 $inline->add($pod);
28 }
29
30 $inline->save;
31}
32
33{
e4d40db1 34 package My::Output;
35
36 sub new {
37 my $class = shift;
38 my $dzil = shift;
39
40 return bless { dzil => $dzil }, $class;
41 }
42
43 sub write {
44 my $self = shift;
45 my $name = shift;
46 my $content = shift;
47
560acb8f 48 $name =~ s/^moose_cookbook_//;
49
e4d40db1 50 $self->{dzil}->add_file(
51 Dist::Zilla::File::InMemory->new(
829433c4 52 name => "t/recipes/$name",
e4d40db1 53 content => $content,
54 )
55 );
56
57 return 1;
58 }
59}
60
611;