[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] CGI::Application::Dispatch::BuildURI module



Kensuke Kaneko wrote:
> Hello, everyone!
> 
> I made a module named CGI::Application::Dispatch::BuildURI.
> This module resolve a relative URI path's  problem when writing template files.
> 
> When I use CGI::Application::Dispatch, I often confused by relative
> URI path difference.
> For example, following two URI call same module and same runmode, but
> Browser follow different link whether URI including PATH_INFO or not.
> 
> http://www.example.com/example.cgi
> http://www.example.com/example.cgi/start/do_start
> 
> So, I provide build_uri() method, this method generates URI including
> complete PATH_INFO.
> This build_uri() method is used on each runmode method.

So, if I understand you correctly, there are 2 reasons for this module.

1 - When you use C::A::Dispatch you can have links that actually go to a
module/run_mode without explicitly specifying them because you can set
the default in the application. And these links don't look like their
counterparts.

2 - Easily create a link to a module/run_mode pair for your templates
when using C::A::Dispatch

I've never had a problem with either of these, but that doesn't mean
they can't be made simpler.

> use CGI::Application::Dispatch::BuildURI;
> 
> sub do_start
> {
>     my $self = shift;
>     my $location = $self->build_uri(
>         module => 'start',
>         rm => 'do_start',
>         query_string => 'key=value',
>     );
>     # $location is 'http://www.example.com/example.cgi/start/do_start?key=value'
> }

[snip]

> I would upload this module to CPAN, but I am worried about two reasons.
> 
> First, whether module name is correct or not.
> If I use common name, I occupy valuable namespace.
> This module is my first work, so I don't know a custom.

I'm ok with the name. It seems pretty intuitive to me.

> Second, whether my test is enough or not.
> I read 'Perl medic' and perldoc Test::Tutorial, but this is my first
> test code, I am worried about my test is not enough.

Well, your module is pretty small, which means that it doesn't need many
tests. If you're concerned about whether your test are complete enough,
you might look at find out your test coverage. Using tools like
Devel::Cover (or if your using Module::Build instead of MakeMaker, it's
as easy as './Build testcover').

Test coverage isn't everything, but it will help you identify obvious
decision trees that aren't covered in your test suite.

> I upload tarball which made by 'make dist' and passed 'make test' on
> my Perl(v5.8.6).
> http://www.kyanny.net/lib/CGI-Application-Dispatch-BuildURI-0.01.tar.gz
> Please tell me your opinion!

Just a couple more nick-picky items:

+ remove the 'use 5.008006;' line from the top of you Makefile.pm.
There's no reason to limit yourself to that strict a version of perl
since this module would probably work for anything 5.6+
+ change line #6 of t/03move.t to have the number of test in it:
   use Test::More tests => 3;
You should almost always specify the number of tests that need to run
(unless you are still developing, or the number is too dynamic).

Congrats on your first module.

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.