summaryrefslogtreecommitdiff
path: root/inc/ExtractInlineTests.pm
diff options
context:
space:
mode:
Diffstat (limited to 'inc/ExtractInlineTests.pm')
-rw-r--r--inc/ExtractInlineTests.pm58
1 files changed, 58 insertions, 0 deletions
diff --git a/inc/ExtractInlineTests.pm b/inc/ExtractInlineTests.pm
new file mode 100644
index 0000000..e2cda0a
--- /dev/null
+++ b/inc/ExtractInlineTests.pm
@@ -0,0 +1,58 @@
+package inc::ExtractInlineTests;
+
+use Moose;
+
+with 'Dist::Zilla::Role::FileGatherer';
+
+use File::Find::Rule;
+use inc::MyInline;
+use Test::Inline;
+
+sub gather_files {
+ my $self = shift;
+ my $arg = shift;
+
+ my $inline = Test::Inline->new(
+ verbose => 0,
+ ExtractHandler => 'My::Extract',
+ ContentHandler => 'My::Content',
+ OutputHandler => My::Output->new($self),
+ );
+
+ for my $pod (
+ File::Find::Rule->file->name(qr/\.pod$/)->in('lib/Moose/Cookbook') ) {
+ $inline->add($pod);
+ }
+
+ $inline->save;
+}
+
+{
+ package My::Output;
+
+ sub new {
+ my $class = shift;
+ my $dzil = shift;
+
+ return bless { dzil => $dzil }, $class;
+ }
+
+ sub write {
+ my $self = shift;
+ my $name = shift;
+ my $content = shift;
+
+ $name =~ s/^moose_cookbook_//;
+
+ $self->{dzil}->add_file(
+ Dist::Zilla::File::InMemory->new(
+ name => "t/recipes/$name",
+ content => $content,
+ )
+ );
+
+ return 1;
+ }
+}
+
+1;