[Rt-devel] Re: [PATCH] DBIx::SB::Record.pm aliases cleanup and
docs
Ruslan U. Zakirov
Ruslan.Zakirov at miet.ru
Thu May 5 11:37:03 EDT 2005
Tatsuhiko Miyagawa wrote:
> On 5/6/05, Ruslan U. Zakirov <Ruslan.Zakirov at miet.ru> wrote:
>
>> Hello, Jesse, Tatsuhiko and all.
>>
>>I've added maintainer of the capitalization.pm to notify about bug in
>>his module that is described in the bottom of this mail.
>
>
> Oh, I've never thought someone actually uses this pragma! :)
:)
>>>First, I had some time to try it but with no success. I didn't find way
>>>to drop capitalization in current module from module itself. This module
>>>is for external users, that is reason why pragma exists at all. I'll try
>>>it again under debugger, may be today tonight, just to understand why it
>>>doesn't work in such way.
>>
>>I've tried again and have found that capitalization.pm works from module
>>itself only if you put it usage in the bottom of the module after all
>>sub declarations.
>
>
> Is allowing "no capitalization" to no-capitalize functions/methods of
> the caller(0) package considered useful?
DBIx::SB provide both variants of API with handwriten aliases. We tried
to use your pragma to don't maintain aliases.
> .
>
>>Yes, it also confirmed and should be fixed. Examples from debug log:
>>method 'LoadByCol' at .../capitalization.pm line 23.
>>alias 'load_by_col' at .../capitalization.pm line 25.
>>method '_Set' at .../capitalization.pm line 23.
>>alias '_Set' at .../capitalization.pm line 25.
>>method '_PrimaryKey' at ...
>>alias '_Primary_key' at ...
>
>
> Do you want _primary_key here?
Yes. I've wrote fix for this. Attached.
Another problem I see is methods with upper case sequences in name, like
special subs(AUTOLOAD, DESTROY) or normal methods like ACL, ID. It's not
showstopper for DBIx::SB, but "bug"/"undocumented feature" in the pragma.
--
Regards, Ruslan.
-------------- next part --------------
Only in capitalization-0.01-cub1/: Makefile.old
diff -ru capitalization-0.01/capitalization.pm capitalization-0.01-cub1/capitalization.pm
--- capitalization-0.01/capitalization.pm 2003-02-10 02:14:55.000000000 +0000
+++ capitalization-0.01-cub1/capitalization.pm 2005-04-12 15:24:46.460000000 +0000
@@ -30,6 +30,7 @@
sub nocap {
my $method = shift;
+ $method =~ s/(?<=[^a-zA-Z])([A-Z]+)/lc($1)/eg;
$method =~ s/(?<=[a-z])([A-Z]+)/"_" . lc($1)/eg;
lcfirst $method;
}
diff -ru capitalization-0.01/t/01_capital.t capitalization-0.01-cub1/t/01_capital.t
--- capitalization-0.01/t/01_capital.t 2003-02-10 02:14:55.000000000 +0000
+++ capitalization-0.01-cub1/t/01_capital.t 2005-04-12 15:17:50.560000000 +0000
@@ -5,6 +5,6 @@
no capitalization qw(Module::LikeJava);
my $m = Module::LikeJava->new;
-can_ok $m, qw(foo_and_bar bar_and_baz fooAndBar BarAndBAZ);
+can_ok $m, qw(foo_and_bar bar_and_baz fooAndBar BarAndBAZ _bar);
diff -ru capitalization-0.01/t/lib/Module/LikeJava.pm capitalization-0.01-cub1/t/lib/Module/LikeJava.pm
--- capitalization-0.01/t/lib/Module/LikeJava.pm 2003-02-10 02:14:55.000000000 +0000
+++ capitalization-0.01-cub1/t/lib/Module/LikeJava.pm 2005-04-12 15:19:29.380000000 +0000
@@ -7,4 +7,6 @@
sub BarAndBAZ { }
+sub _Bar { }
+
1;
More information about the Rt-devel
mailing list