Update docs, add simple tests
Nilson Santos Figueiredo JĂșnior [Fri, 30 Jan 2009 20:09:08 +0000 (20:09 +0000)]
lib/Catalyst/View/Component/SubInclude.pm
lib/Catalyst/View/Component/SubInclude/ESI.pm
lib/Catalyst/View/Component/SubInclude/SubRequest.pm
t/00-load.t [new file with mode: 0644]
t/pod-coverage.t [new file with mode: 0644]
t/pod.t [new file with mode: 0644]

index 97023c6..94f7faa 100644 (file)
@@ -72,6 +72,13 @@ Configuration file example:
       subinclude_plugin   ESI
   </View::TT>
 
+If writing your own plugin, keep in kind plugins are required to implement a 
+class method C<generate_subinclude> with the following signature:
+
+  sub generate_subinclude {
+      my ($class, $c, @args) = @_;
+  }
+
 =cut
 
 has 'subinclude_plugin' => (
index f2b499a..5af70c1 100644 (file)
@@ -37,14 +37,14 @@ Edge Side Includes (ESI) include directives. This is a feature implemented by
 Varnish (L<http://varnish.projects.linpro.no/>) which allows cache-efficient 
 uses of includes.
 
-=head1 STASH FUNCTION
+=head1 CLASS METHODS
 
-=head2 C<subinclude( @args )>
+=head2 C<generate_subinclude( $c, @args )>
 
 This will roughly translate to the following code:
 
   my $url = $c->uri_for( @args );
-  <!--esi <esi:include src="$url" /> -->
+  return '<!--esi <esi:include src="$url" /> -->';
 
 Notice that the stash will always be empty. This behavior could be configurable
 in the future through an additional switch - for now, this behavior guarantees a
index 5c8cf7a..c40a77d 100644 (file)
@@ -2,6 +2,9 @@ package Catalyst::View::Component::SubInclude::SubRequest;
 use warnings;
 use strict;
 
+use Carp qw/croak/;
+use namespace::clean qw/croak/;
+
 =head1 NAME
 
 Catalyst::View::Component::SubInclude::SubRequest - Sub-requests plugin for C::V::Component::SubInclude
@@ -48,9 +51,9 @@ to render the subinclude contents.
 
 It requires L<Catalyst::Plugin::SubRequest>.
 
-=head1 STASH FUNCTION
+=head1 CLASS METHODS
 
-=head2 C<subinclude( $path, @args )>
+=head2 C<generate_subinclude( $c, $path, @args )>
 
 This will translate to the following sub-request call:
 
diff --git a/t/00-load.t b/t/00-load.t
new file mode 100644 (file)
index 0000000..9b3b75d
--- /dev/null
@@ -0,0 +1,11 @@
+#!perl -T\r
+\r
+use Test::More tests => 3;\r
+\r
+BEGIN {\r
+       use_ok( 'Catalyst::View::Component::SubInclude' );\r
+    use_ok( 'Catalyst::View::Component::SubInclude::SubRequest' );\r
+    use_ok( 'Catalyst::View::Component::SubInclude::ESI' );\r
+}\r
+\r
+diag( "Testing Catalyst::View::Component::SubInclude $Catalyst::View::Component::SubInclude::VERSION, Perl $], $^X" );\r
diff --git a/t/pod-coverage.t b/t/pod-coverage.t
new file mode 100644 (file)
index 0000000..96d1c52
--- /dev/null
@@ -0,0 +1,6 @@
+#!perl -T\r
+\r
+use Test::More;\r
+eval "use Test::Pod::Coverage 1.04";\r
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;\r
+all_pod_coverage_ok();\r
diff --git a/t/pod.t b/t/pod.t
new file mode 100644 (file)
index 0000000..f062570
--- /dev/null
+++ b/t/pod.t
@@ -0,0 +1,6 @@
+#!perl -T\r
+\r
+use Test::More;\r
+eval "use Test::Pod 1.14";\r
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;\r
+all_pod_files_ok();\r