Makefile.PL and maint code
[gitmo/Role-Tiny.git] / maint / Makefile.PL.include
diff --git a/maint/Makefile.PL.include b/maint/Makefile.PL.include
new file mode 100644 (file)
index 0000000..53e335d
--- /dev/null
@@ -0,0 +1,60 @@
+use strict;
+use warnings FATAL => 'all';
+
+{
+  package MY;
+
+  {
+    no warnings 'once'; push @ExtUtils::MakeMaker::Overridable, 'find_tests';
+  }
+
+  sub find_tests {
+    shift->SUPER::find_tests.' xt/*.t';
+  }
+
+  sub postamble { 'include maint/Makefile.include' }
+}
+
+{
+  no warnings 'redefine';
+  sub WriteMakefile {
+    my %args = @_;
+    ExtUtils::MakeMaker::WriteMakefile(
+      %args,
+      AUTHOR => 'Matt S Trout <mst@shadowcat.co.uk>',
+      ABSTRACT_FROM => $args{VERSION_FROM},
+    );
+  }
+}
+
+sub manifest_include {
+  use autodie;
+  my @files = @_;
+  my @parts;
+  while (my ($dir, $spec) = splice(@files, 0, 2)) {
+    my $re = ($dir ? $dir.'/' : '').
+      ((ref($spec) eq 'Regexp')
+        ? $spec
+        : !ref($spec)
+          ? ".*\Q${spec}\E"
+          : die "spec must be string or regexp, was: ${spec} (${\ref $spec})");
+    push @parts, $re;
+  }
+  my $final = '^(?!'.join('|', map "${_}\$", @parts).')';
+  open my $skip, '>', 'MANIFEST.SKIP';
+  print $skip "${final}\n";
+  close $skip;
+}
+
+manifest_include(
+  'lib' => '.pm',
+  't' => '.t',
+  't/lib' => '.pm',
+  'xt' => '.t',
+  'xt/lib' => '.pm',
+  '' => qr{([^/]+).PL},
+  '' => qr{Changes|MANIFEST|README|META\.yml},
+  'maint' => qr{[^.].*},
+);
+
+1;