1. Shlomi Fish
  2. perl-SVN-RaWeb-Light

Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed 870b285

Added t/pod.t and t/pod-coverage.t and made sure we have full POD coverage.

  • Participants
  • Parent commits a7af439
  • Branches default

Comments (0)

Files changed (11)

File Build.PL

View file
 use lib File::Spec->catdir(File::Spec->curdir(), "inc");
 
 use Test::Run::Builder;
+use SVN::RaWeb::Light::GenHelp;
 
-open O, ">", "lib/SVN/RaWeb/Light/Help.pm";
-print O <<'EOF';
-package SVN::RaWeb::Light::Help;
-
-sub print_data
-{
-    local $/;
-    print <DATA>;
-}
-
-1;
-EOF
-
-print O "__DATA__\n";
-
-{
-    local $/;
-    open I, "<", "docs/Help.html";
-    print O <I>;
-    close(I);
-}
-close(O);
+_gen_help();
 
 my $build = Test::Run::Builder->new(
     module_name => 'SVN::RaWeb::Light',

File MANIFEST

View file
 COPYING
 docs/Help.html
 examples/berlios.pl
+inc/SVN/RaWeb/Light/GenHelp.pm
 inc/Test/Run/Builder.pm
 lib/SVN/RaWeb/Light/Help.pm
 lib/SVN/RaWeb/Light.pm
 t/03trans_unit.t
 t/04exceptions.t
 TODO
+t/pod-coverage.t
+t/pod.t
 t/SVN-RaWeb-Light.t

File Makefile.PL

View file
 use ExtUtils::MakeMaker;
 
-open O, ">", "lib/SVN/RaWeb/Light/Help.pm";
-print O <<'EOF';
-package SVN::RaWeb::Light::Help;
+use File::Spec;
+use lib File::Spec->catdir(File::Spec->curdir(), "inc");
 
-sub print_data
-{
-    local $/;
-    print <DATA>;
-}
+use SVN::RaWeb::Light::GenHelp;
 
-1;
-EOF
-
-print O "__DATA__\n";
-
-{
-    local $/;
-    open I, "<", "docs/Help.html";
-    print O <I>;
-    close(I);
-}
-close(O);
+_gen_help();
 
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.

File SVN/RaWeb/Light/Test/LimitOutput.pm

View file
 
 use base 'SVN::RaWeb::Light';
 
-sub process_dir
+sub _process_dir
 {
     my $self = shift;
-    $self->get_dir();
-    $self->print_items_list();
+    $self->_get_dir();
+    $self->_print_items_list();
 }
 
 1;
 
 use base 'SVN::RaWeb::Light';
 
-sub process_dir
+sub _process_dir
 {
     my $self = shift;
-    $self->get_dir();
+    $self->_get_dir();
 
-    print $self->render_top_url_translations_text();
-    $self->print_items_list();
+    print $self->_render_top_url_translations_text();
+    $self->_print_items_list();
 }
 
 1;

File inc/SVN/RaWeb/Light/GenHelp.pm

View file
+sub _gen_help
+{
+open O, ">", "lib/SVN/RaWeb/Light/Help.pm";
+print O <<"EOF";
+package SVN::RaWeb::Light::Help;
+
+\=head1 NAME
+
+SVN::RaWeb::Light::Help - Generate the Help HTML for SVN::RaWeb::Light.
+
+\=head1 SYNOPSIS
+
+Warning! This moduls is auto-generated.
+
+\=head1 FUNCTIONS
+
+\=head2 print_data()
+
+Prints the HTML data to the standard output.
+
+\=head1 AUTHOR
+
+Shlomi Fish, E<lt>shlomif@iglu.org.ilE<gt>
+
+\=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2004 by Shlomi Fish
+
+This library is free software; you can redistribute it and/or modify
+it under the terms of the MIT/X11 license.
+
+\=cut
+
+sub print_data
+{
+    local \$/;
+    print <DATA>;
+}
+
+1;
+EOF
+
+print O "__DATA__\n";
+
+{
+    local $/;
+    open I, "<", "docs/Help.html";
+    print O <I>;
+    close(I);
+}
+close(O);
+}
+
+1;
+

File lib/SVN/RaWeb/Light.pm

View file
     my $self = {};
     my $class = shift;
     bless $self, $class;
-    $self->initialize(@_);
+    $self->_init(@_);
     return $self;
 }
 
-sub initialize
+sub _init
 {
     my $self = shift;
     
     return $self;
 }
 
-sub get_user_url_translations
+sub _get_user_url_translations
 {
     my $self = shift;
 
 
 # TODO :
 # Create a way for the user to specify one extra url translation of his own.
-sub get_url_translations
+sub _get_url_translations
 {
     my $self = shift;
 
             () :
             (@{$self->{'url_translations'}})
         ),
-        @{$self->get_user_url_translations()},
+        @{$self->_get_user_url_translations()},
     ];
 }
 
-sub get_mode
+sub _get_mode
 {
     my $self = shift;
 
 }
 
 # This function must be called before rev_num() and url_suffix() are valid.
-sub calc_rev_num
+sub _calc_rev_num
 {
     my $self = shift;
 
     }
     
     $self->rev_num($rev_num);
-    $self->url_suffix($self->get_url_suffix_with_extras());
+    $self->url_suffix($self->_get_url_suffix_with_extras());
     $self->esc_url_suffix(escape($self->url_suffix()));
 }
 
 # Gets the URL suffix calculated with optional extra components.
-sub get_url_suffix_with_extras
+sub _get_url_suffix_with_extras
 {
     my $self = shift;
     my $components = shift;
     }
 }
 
-sub calc_path
+sub _calc_path
 {
     my $self = shift;
 
     }
     if ($path =~ /\/\//)
     {
-        die +{ 'callback' => sub { $self->multi_slashes(); } };
+        die +{ 'callback' => sub { $self->_multi_slashes(); } };
     }
 
     $path =~ s!^/!!;
     $self->path($path);
 }
 
-sub get_correct_node_kind
+sub _get_correct_node_kind
 {
     my $self = shift;
     return $self->should_be_dir() ? $SVN::Node::dir : $SVN::Node::file;
 }
 
-sub get_escaped_path
+sub _get_escaped_path
 {
     my $self = shift;
     return escape($self->path());
 }
 
-sub check_node_kind
+sub _check_node_kind
 {
     my $self = shift;
     my $node_kind = shift;
                 },
         };        
     }
-    elsif ($node_kind ne $self->get_correct_node_kind())
+    elsif ($node_kind ne $self->_get_correct_node_kind())
     {
         die +{
             'callback' =>
     }
 }
 
-sub get_esc_item_url_translations
+sub _get_esc_item_url_translations
 {
     my $self = shift;
 
                 'label' => escape($_->{'label'}),
             }
             }
-            @{$self->get_url_translations('is_list_item' => 1)}
+            @{$self->_get_url_translations('is_list_item' => 1)}
         )
         ];
     }
     return $self->{'escaped_item_url_translations'};
 }
 
-sub render_list_item
+sub _render_list_item
 {
     my ($self, $args) = (@_);
 
         {
             " [<a href=\"$_->{url}$args->{path_in_repos}\">$_->{label}</a>]"
         }
-        @{$self->get_esc_item_url_translations()}
+        @{$self->_get_esc_item_url_translations()}
         ) .
         "</li>\n";    
 }
 
-sub get_esc_up_path
+sub _get_esc_up_path
 {
     my $self = shift;
 
     return escape($1);    
 }
 
-sub real_render_up_list_item
+sub _real_render_up_list_item
 {
     my $self = shift;
-    return $self->render_list_item(
+    return $self->_render_list_item(
         {
             'link' => "../",
             'label' => "..",
-            'path_in_repos' => $self->get_esc_up_path(),
+            'path_in_repos' => $self->_get_esc_up_path(),
         }
     );
 }
 
 # The purpose of this function ios to get the list item of the ".." directory
 # that goes one level up in the repository.
-sub render_up_list_item
+sub _render_up_list_item
 {
     my $self = shift;
     # If the path is the root - then we cannot have an upper directory
     }
     else
     {
-        return $self->real_render_up_list_item();
+        return $self->_real_render_up_list_item();
     }
 }
 
 # This method gets the escaped path along with a potential trailing slash
 # (if it isn't empty)
-sub get_normalized_path
+sub _get_normalized_path
 {
     my $self = shift;
 
     return $url;
 }
 
-sub render_regular_list_item
+sub _render_regular_list_item
 {
     my ($self, $entry) = @_;
 
         $escaped_name .= "/";
     }
 
-    return $self->render_list_item(
+    return $self->_render_list_item(
         {
             (map { $_ => $escaped_name } qw(link label)),
             'path_in_repos' => 
-                (escape($self->get_normalized_path()).$escaped_name),
+                (escape($self->_get_normalized_path()).$escaped_name),
         }
     );
 }
 
-sub render_top_url_translations_text
+sub _render_top_url_translations_text
 {
     my $self = shift;
     
     my $top_url_translations =
-        $self->get_url_translations('is_list_item' => 0);
+        $self->_get_url_translations('is_list_item' => 0);
     my $ret = "";
     if (@$top_url_translations)
     {
         $ret .= "<table border=\"1\">\n";
         foreach my $trans (@$top_url_translations)
         {
-            my $url = $self->get_normalized_path();
+            my $url = $self->_get_normalized_path();
             my $escaped_url = escape($trans->{'url'} . $url);
             my $escaped_label = escape($trans->{'label'});
             $ret .= "<tr><td><a href=\"$escaped_url\">$escaped_label</a></td></tr>\n";
     return $ret;
 }
 
-sub render_dir_header
+sub _render_dir_header
 {
     my $self = shift;
 
     my $title = "Revision ". $self->rev_num() . ": /" . 
-        $self->get_escaped_path();
+        $self->_get_escaped_path();
     my $ret = "";
     $ret .= $self->cgi()->header();
     $ret .= "<html><head><title>$title</title></head>\n";
     return $ret;
 }
 
-sub get_items_list_items_order
+sub _get_items_list_items_order
 {
     my $self = shift;
     return [ sort { $a cmp $b } keys(%{$self->dir_contents()}) ];
 }
 
-sub get_items_list_regular_items
+sub _get_items_list_regular_items
 {
     my $self = shift;
     return 
         [map 
         {
-            $self->render_regular_list_item($_)
+            $self->_render_regular_list_item($_)
         } 
-        (@{$self->get_items_list_items_order()})
+        (@{$self->_get_items_list_items_order()})
         ];
 }
 
-sub get_items_list_items
+sub _get_items_list_items
 {
     my $self = shift;
     return 
     [
-        $self->render_up_list_item(),
-        @{$self->get_items_list_regular_items()},
+        $self->_render_up_list_item(),
+        @{$self->_get_items_list_regular_items()},
     ];
 }
 
-sub print_items_list
+sub _print_items_list
 {
     my ($self) = @_;
     print "<ul>\n";
     
-    print @{$self->get_items_list_items()};
+    print @{$self->_get_items_list_items()};
     print "</ul>\n";
 }
 
-sub print_control_section
+sub _print_control_section
 {
     my $self = shift;
     print "<ul>\n" .
         "<li><a href=\"./?mode=help\">Show Help Screen</a></li>\n" .
-        "<li><a href=\"./" . escape($self->get_url_suffix_with_extras("panel=1")) . "\">Show Control Panel</a></li>\n" .
+        "<li><a href=\"./" . escape($self->_get_url_suffix_with_extras("panel=1")) . "\">Show Control Panel</a></li>\n" .
         "</ul>\n";
 }
 
-sub get_dir
+sub _get_dir
 {
     my $self = shift;
 
     $self->dir_contents($dir_contents);
 }
 
-sub process_dir
+sub _process_dir
 {
     my $self = shift;
-    $self->get_dir();
-    print $self->render_dir_header();
-    print $self->render_top_url_translations_text();
-    $self->print_items_list();
-    $self->print_control_section();
+    $self->_get_dir();
+    print $self->_render_dir_header();
+    print $self->_render_top_url_translations_text();
+    $self->_print_items_list();
+    $self->_print_control_section();
     print "</body></html>\n";
 }
 
-sub process_file
+sub _process_file
 {
     my $self = shift;
 
     print $buffer;
 }
 
-sub process_help
+sub _process_help
 {
     my $self = shift;
 
     SVN::RaWeb::Light::Help::print_data();
 }
 
-sub real_run
+sub _real_run
 {
     my $self = shift;
     my $cgi = $self->cgi();
 
-    if ($self->get_mode() eq "help")
+    if ($self->_get_mode() eq "help")
     {
-        return $self->process_help();
+        return $self->_process_help();
     }
     if ($cgi->param("panel"))
     {
         return 0;
     }
     
-    $self->calc_rev_num();
-    $self->calc_path();
+    $self->_calc_rev_num();
+    $self->_calc_path();
 
     my $node_kind =
         $self->svn_ra()->check_path($self->path(), $self->rev_num());
 
-    $self->check_node_kind($node_kind);
+    $self->_check_node_kind($node_kind);
 
     if ($node_kind eq $SVN::Node::dir)
     {
-        return $self->process_dir();
+        return $self->_process_dir();
     }
     # This means $node_kind eq $SVN::Node::file
     else
     {
-        return $self->process_file();
+        return $self->_process_file();
     }
 }
 
 
     my @ret;
     eval {
-        @ret = $self->real_run();
+        @ret = $self->_real_run();
     };
 
     if ($@)
     }
 }
 
-sub multi_slashes
+sub _multi_slashes
 {
     my $self = shift;
     print $self->cgi()->header();
 relative to the script's base directory. The complete path would be the 
 URL in the URL translation appended by the path that the script points to.
 
+=head1 METHODS
+
+=head2 my $app = SVN::RaWeb::Light->new(...)
+
+Initialises a new application.
+
+=head2 $app->run();
+
+Runs it in the current process.
+
 =head1 AUTHOR
 
 Shlomi Fish, E<lt>shlomif@iglu.org.ilE<gt>

File t/02unit.t

View file
 
     my $svn_ra_web = SVN::RaWeb::Light->new('url' => "http://svn-i.shlomifish.org/svn/myrepos/");
 
-    $svn_ra_web->multi_slashes();
+    $svn_ra_web->_multi_slashes();
 
     my $results = get_out_buffer();
 
 
     my $svn_ra_web = SVN::RaWeb::Light->new('url' => "http://svn-i.shlomifish.org/svn/myrepos/");
 
-    my $url_trans = $svn_ra_web->get_url_translations();
+    my $url_trans = $svn_ra_web->_get_url_translations();
 
     # TEST
     is (ref($url_trans), "ARRAY", 
             ],
         );
 
-    my $url_trans = $svn_ra_web->get_url_translations();
+    my $url_trans = $svn_ra_web->_get_url_translations();
 
     # TEST
     is (ref($url_trans), "ARRAY", 
             'url' => "http://svn-i.shlomifish.org/svn/myrepos/",
         );
 
-    $svn_ra_web->calc_rev_num();
+    $svn_ra_web->_calc_rev_num();
 
     # TEST
     is($svn_ra_web->rev_num(), "600", 
             'url' => "http://svn-i.shlomifish.org/svn/myrepos/",
         );
 
-    $svn_ra_web->calc_rev_num();
+    $svn_ra_web->_calc_rev_num();
 
     # TEST
     is($svn_ra_web->rev_num(), "5267",
             'url' => "http://svn-i.shlomifish.org/svn/myrepos/",
         );
 
-    $svn_ra_web->calc_path();
+    $svn_ra_web->_calc_path();
 
     # TEST
     is($svn_ra_web->path(), "trunk/build.txt",
             'url' => "http://svn-i.shlomifish.org/svn/myrepos/",
         );
 
-    $svn_ra_web->calc_path();
+    $svn_ra_web->_calc_path();
 
     # TEST
     is($svn_ra_web->path(), "trunk/src/perl",
             'url' => "http://svn-i.shlomifish.org/svn/myrepos/",
         );
 
-    $svn_ra_web->calc_rev_num();
+    $svn_ra_web->_calc_rev_num();
 
     # TEST
     is($svn_ra_web->url_suffix(), "?trans_hide_all=1", 
         );
 
     is(
-        $svn_ra_web->get_url_suffix_with_extras(@{$args{'func_params'}}), 
+        $svn_ra_web->_get_url_suffix_with_extras(@{$args{'func_params'}}), 
         $args{'result'},
         $args{'msg'}
     );

File t/03trans_unit.t

View file
         );
 
     is_deeply(
-        $svn_raweb->get_url_translations(
+        $svn_raweb->_get_url_translations(
             'is_list_item' => $is_list_item,
         ),
         $results,

File t/04exceptions.t

View file
 use base 'SVN::RaWeb::Light';
 
 # Throw a hash reference without a 'callback' parameter.
-sub real_run
+sub _real_run
 {
     die +{ 'one' => "two", 'shlomi' => "fish", };
 }
 use base 'SVN::RaWeb::Light';
 
 # Throw a hash reference without a 'callback' parameter.
-sub real_run
+sub _real_run
 {
     die [ "eenie", "meenie", "mynie", "mow"];
 }
 use base 'SVN::RaWeb::Light';
 
 # Throw a hash reference without a 'callback' parameter.
-sub real_run
+sub _real_run
 {
     die "Hallelujah - an exception was thrown";
 }

File t/pod-coverage.t

View file
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();

File t/pod.t

View file
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();