Changeset 35361 for lang/perl

Show
Ignore:
Timestamp:
09/14/09 03:46:30 (4 years ago)
Author:
ktat
Message:

Checking in changes prior to tagging of version 0.09. Changelog diff is:

=== Changes
==================================================================
--- Changes (revision 39140)
+++ Changes (local)
@@ -1,9 +1,15 @@

Revision history for Util-Any


-0.07 2009/04/12 03:58
+0.09 2009/09/13 03:31
+ Fix bug, prefix doesn't work when using '-kind' style.
+
+0.08 2009/09/11 15:58

support Sub::Exporter

- support some of exporting ways from Sub::Exporter
+ support some of exporting ways of Sub::Exporter


+0.07 2009/04/12 03:58
+ Fix bug when inheriting
+

0.06 2009/03/22 14:55

support Exporter and Exporter::Simple


Location:
lang/perl/Util-Any/trunk
Files:
7 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Util-Any/trunk/Changes

    r32282 r35361  
    11Revision history for Util-Any 
    22 
     30.09    2009/09/13 03:31 
     4        Fix bug, prefix doesn't work when using '-kind' style. 
     5 
     60.08    2009/09/11 15:58 
     7        support Sub::Exporter 
     8        support some of exporting ways of Sub::Exporter 
     9 
    3100.07    2009/04/12 03:58 
    4         support Sub::Exporter 
    5         support some of exporting ways from Sub::Exporter 
     11        Fix bug when inheriting 
    612 
    7130.06    2009/03/22 14:55 
  • lang/perl/Util-Any/trunk/MANIFEST

    r32282 r35361  
    99t/pod-coverage.t 
    1010t/pod.t 
     11t/01-unit.t 
     12t/01-util.t 
    1113t/01-util-kind-list.t 
    1214t/01-util-kind-scalar.t 
     
    2224t/01-util-kind-my-prefix.t 
    2325t/02-util-func-scalar-prefix.t 
     26t/02-util-func-scalar-prefix-sign.t 
    2427t/01-util-kind-all-prefix.t 
    2528t/03-debug.t 
     
    4851t/11-sub-exporter-full-all.t 
    4952t/12-sub-exporter-like-export.t 
     53t/13-inherit.t 
    5054t/lib/MyUtil.pm 
    5155t/lib/MyUtilBase.pm 
     
    5761t/lib/UtilSubExporter2.pm 
    5862t/lib/exampleHello.pm 
     63t/lib/Inherit.pm 
     64t/lib/InheritSub.pm 
     65t/lib/One.pm 
     66t/lib/Two.pm 
  • lang/perl/Util-Any/trunk/lib/Util/Any.pm

    r33696 r35361  
    4242      $prefix = $kind_prefix                             ? $kind_prefix   : 
    4343                ($opt{module_prefix} and $module_prefix) ? $module_prefix : 
    44                 $opt{prefix}                             ? lc($kind) . '_': ''; 
     44                $opt{prefix}                             ? lc(join "",$kind =~m{(\w+)}g) . '_': ''; 
    4545 
    4646      my $evalerror = ''; 
     
    256256=head1 NAME 
    257257 
    258 Util::Any - Export any utilities and To create your own Util::Any 
     258Util::Any - to export any utilities and to create your own Utilitie module 
    259259 
    260260=cut 
    261261 
    262 our $VERSION = '0.07'; 
     262our $VERSION = '0.09'; 
    263263 
    264264=head1 SYNOPSIS 
     
    313313You can create your own module and use this in the same way as Util::Any like the following. 
    314314 
    315  use YourUtil qw/list/; 
     315 use YourUtil -list; 
    316316 
    317317see C<CREATE YOUR OWN Util::Any>, in detail. 
     
    321321=head2 use Util::Any (KIND) 
    322322 
    323  use Util::Any qw/list hash/; 
     323 use Util::Any -list, -hash; 
    324324 
    325325Give list of kinds of modules. All functions in moduls are exporeted. 
     
    327327=head2  use Util::Any {KIND => [FUNCTIONS], ...}; 
    328328 
    329  use Util::Any {list => ['uniq'], hash => ['lock_keys']}; 
     329 use Util::Any {-list => ['uniq'], -hash => ['lock_keys']}; 
    330330 
    331331Give hash ref whose key is kind and value is function names. 
     
    342342add kind prefix to function name. 
    343343 
    344  use Util::Any qw/list/, {prefix => 1}; 
     344 use Util::Any -list, {prefix => 1}; 
    345345  
    346346 list_uniq(1,2,3,4,5); # it is List::More::Utils's uniq function 
     
    356356If you pass debug value, warn or die. 
    357357 
    358  use Util::Any qw/list/, {debug => 1}; # warn 
    359  use Util::Any qw/list/, {debug => 2}; # die 
     358 use Util::Any -list, {debug => 1}; # warn 
     359 use Util::Any -list, {debug => 2}; # die 
    360360 
    361361=back 
     
    481481 use Util::Any -Base; # or use base qw/Util::Any/; 
    482482 our $Utils = clone $Util::Any::Utils; 
    483  push @{$Utils->{list}}, qw/Your::Favorite::List::Utils/; 
     483 push @{$Utils->{-list}}, qw/Your::Favorite::List::Utils/; 
    484484  
    485485 1; 
     
    487487In your code; 
    488488 
    489  use Util::Yours qw/list/; 
     489 use Util::Yours -list; 
    490490 
    491491=head2 $Utils STRUCTURE 
     
    495495 $Utils => { 
    496496    # simply put module names 
    497     kind1 => [qw/Module1 Module2 ..../], 
    498     # Module name and its prefix 
    499     kind2 => [ [Module1 => 'module_prefix'], ... ], 
     497    -kind1 => [qw/Module1 Module2 ..../], 
     498    -# Module name and its prefix 
     499    -kind2 => [ [Module1 => 'module_prefix'], ... ], 
    500500    # limit functions to be exported 
    501     kind3 => [ [Module1, 'module_prefix', [qw/func1 func2/] ], ... ], 
     501    -kind3 => [ [Module1, 'module_prefix', [qw/func1 func2/] ], ... ], 
    502502    # as same as above except not specify modul prefix 
    503     kind4 => [ [Module1, '', [qw/func1 func2/] ], ... ], 
     503    -kind4 => [ [Module1, '', [qw/func1 func2/] ], ... ], 
    504504 }; 
    505505 
     
    547547Util::Any auomaticaly export functions from modules' @EXPORT and @EXPORT_OK. 
    548548In some cases, it is not good idea like Data::Dumper's Dumper and DumperX. 
     549Thease 2 functions are same feature. 
    549550 
    550551So you can limit functions to be exported. 
    551552 
    552553 our $Utils = { 
    553       debug => [ 
     554      -debug => [ 
    554555                ['Data::Dumper', '', 
    555556                ['Dumper']], # only Dumper method is exported. 
     
    560561 
    561562 our $Utils = { 
    562       debug => [ 
     563      -debug => [ 
    563564                ['Data::Dumper', '', 
    564565                 { -select => ['Dumper'] }, # only Dumper method is exported. 
     
    573574 
    574575 our $Utils = { 
    575       debug => [ 
     576      -debug => [ 
    576577                ['Data::Dumper', '', 
    577578                 { -except => ['DumperX'] }, # export functions except DumperX 
     
    588589 
    589590 our $Utils = { 
    590       list  => [ 
     591      -list  => [ 
    591592                 [ 
    592593                  'List::Util', '', 
     
    603604=head2 EXPORTING LIKE Sub::Exporter 
    604605 
    605 It's experimental featrue. not enough tested. and only support '-prefix' and '-as'. 
    606  
    607  use UtilSubExporter list => {-prefix => 'list__', min => {-as => "list___min"}}, 
     606This featrue is not enough tested. and only support '-prefix' and '-as'. 
     607 
     608 use UtilSubExporter -list => {-prefix => 'list__', min => {-as => "list___min"}}, 
    608609                     # The following is normal Sub::Exporter importing 
    609                      -greet => {-prefix => "greet_"}, 
     610                     greet => {-prefix => "greet_"}, 
    610611                     'askme' => {-as => "ask_me"}; 
    611612 
     
    795796L<Exporter>, L<Exporter::Simple>, L<Sub::Exporter> and L<Perl6::Export::Attrs>. 
    796797 
     798Now I try to make L<Util::All> module based on Util::Any. see the following URL. 
     799 
     800 http://github.com/ktat/Util-All 
     801 
    797802=head1 ACKNOWLEDGEMENTS 
    798803 
    799804=head1 COPYRIGHT & LICENSE 
    800805 
    801 Copyright 2008 Ktat, all rights reserved. 
     806Copyright 2008-2009 Ktat, all rights reserved. 
    802807 
    803808This program is free software; you can redistribute it and/or modify it 
  • lang/perl/Util-Any/trunk/t/01-util.t

    r32675 r35361  
    4848} 
    4949 
     50my @isa = @main::ISA; 
     51Util::Any::_base_import('Util::Any', 'main', '-base'); 
     52is($main::ISA[-1], 'Util::Any', 'isa'); 
     53ok(!defined &main::_use_import_module, 'not defined'); 
     54@main::ISA = @isa; 
     55 
     56foreach my $m (['-Exporter'        , 'Exporter'            ], 
     57               ['-ExporterSimple'  , 'Exporter::Simple'    ], 
     58               ['-SubExporter'     , 'Sub::Exporter'       ], 
     59               ['-Perl6ExportAttrs', 'Perl6::Export::Attrs'], 
     60              ) { 
     61  Util::Any::_base_import('Util::Any', 'main', $m->[0]); 
     62  my $file = $m->[1] . '.pm'; 
     63  $file =~s{::}{/}g; 
     64  ok(exists $main::INC{$file}, $file); 
     65  is(&main::_use_import_module(), $m->[1], $m->[1]); 
     66  undef &main::_use_import_module; 
     67  @main::ISA = @isa; 
     68} 
     69 
     70eval { 
     71  Util::Any::_base_import('Util::Any', 'main', "Hoge"); 
     72}; 
     73 
     74ok($@ =~ /cannot understand/, 'unknown option');