Commits

Toby Inkster committed 67ee809

test::pod tool

Comments (0)

Files changed (2)

lib/P5U/Command/TestPod.pm

+package P5U::Command::TestPod;
+
+use 5.010;
+use strict;
+use utf8;
+use P5U-command;
+
+BEGIN {
+	$P5U::Command::TestPod::AUTHORITY = 'cpan:TOBYINK';
+	$P5U::Command::TestPod::VERSION   = '0.001';
+};
+
+use constant {
+	abstract    => q[run Test::Pod on given files],
+	usage_desc  => q[%c testpod %o Files],
+};
+
+sub command_names
+{
+	qw(
+		testpod
+		tp
+	);
+}
+
+sub opt_spec
+{
+	return ()
+}
+
+sub execute
+{
+	require P5U::Lib::TestPod;
+	
+	my ($self, $opt, $args) = @_;
+
+	if (not @$args)
+	{
+		-d 'lib' or $self->usage_error("please provide a list of files/directories");
+		$args = ['lib'];
+	}
+	
+	P5U::Lib::TestPod::->test_pod(@$args);
+}
+
+1;

lib/P5U/Lib/TestPod.pm

+package P5U::Lib::TestPod;
+
+use 5.010;
+use strict;
+use utf8;
+
+BEGIN {
+	$P5U::Command::TestPod::AUTHORITY = 'cpan:TOBYINK';
+	$P5U::Command::TestPod::VERSION   = '0.001';
+};
+
+use Path::Class;
+use Path::Class::Rule;
+use Test::More;
+use Test::Pod;
+
+sub uniq
+{
+	my %already;
+	grep { not $already{"$_"}++ } @_;
+}
+
+sub test_pod
+{
+	my $self = shift;
+	
+	my @files = 
+		uniq
+		map {
+			(-d $_)
+				? Path::Class::Rule::->new->or(
+					Path::Class::Rule::->new->perl_module,
+					Path::Class::Rule::->new->perl_pod,
+					Path::Class::Rule::->new->perl_script,
+					)->all($_)
+				: Path::Class::File::->new($_)
+		} @_;
+	
+	plan tests => scalar @files;
+	pod_file_ok("$_", $_) for @files;
+}
+
+1;