Changeset 36328 for lang/perl

Show
Ignore:
Timestamp:
01/01/10 06:24:41 (3 years ago)
Author:
ktat
Message:

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

=== Changes
==================================================================
--- Changes (revision 40760)
+++ Changes (local)
@@ -1,11 +1,15 @@

Revision history for Util-Any


+0.18 2010/01/01 06:17:05
+ remove List::MoreUtils? from Util::Any itself(they are left in definition).
+ Fix bug: didn't understand argument order, collectory in some case.
+

0.17 2009/10/06 03:32

add -args option to give common arguments to all functions in same kind.

enable to work -all with kind setting. for example

-all, -list => {...}

- fix typo: inherit Perl6::Exprot::Attr and ':ALL' keyword didn't work correctly.
- fix typo: inherit Exproer and ':all' keyword didn't work correctly.
+ fix typo: inherit Perl6::Export::Attr and ':ALL' keyword didn't work correctly.
+ fix typo: inherit Exporter and ':all' keyword didn't work correctly.

Thanks to Richard Jelinek, again.


0.16 2009/09/30 03:16

Location:
lang/perl/Util-Any/trunk
Files:
3 modified

Legend:

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

    r35510 r36328  
    11Revision history for Util-Any 
     2 
     30.18    2010/01/01 06:17:05 
     4        remove List::MoreUtils from Util::Any itself(they are left in definition). 
     5        Fix bug: didn't understand argument order, collectory in some case. 
    26 
    370.17    2009/10/06 03:32 
     
    59        enable to work -all with kind setting. for example 
    610               -all, -list => {...} 
    7         fix typo: inherit Perl6::Exprot::Attr and ':ALL' keyword didn't work correctly. 
    8         fix typo: inherit Exproer and ':all' keyword didn't work correctly. 
     11        fix typo: inherit Perl6::Export::Attr and ':ALL' keyword didn't work correctly. 
     12        fix typo: inherit Exporter and ':all' keyword didn't work correctly. 
    913        Thanks to  Richard Jelinek, again. 
    1014 
  • lang/perl/Util-Any/trunk/lib/Util/Any.pm

    r35510 r36328  
    44use Clone (); 
    55use Carp (); 
    6 use List::MoreUtils (); 
    7 use Module::Pluggable (); 
    86use warnings; 
    97use strict; 
     
    2119 
    2220our $SubExporterImport = 'do_import'; 
     21 
     22# borrow from List::MoreUtils 
     23sub _any (&@) { 
     24    my $f = shift; 
     25    return if ! @_; 
     26    for (@_) { 
     27        return 1 if $f->(); 
     28    } 
     29    return 0; 
     30} 
     31 
     32sub _uniq (@) { 
     33    my %h; 
     34    map { $h{$_}++ == 0 ? $_ : () } @_; 
     35} 
     36# /end 
    2337 
    2438sub import { 
     
    167181    } 
    168182  } else { 
    169     ExportTo::export_to($caller => [map $class . '::' . $_, List::MoreUtils::uniq @export_funcs]); 
     183    ExportTo::export_to($caller => [map $class . '::' . $_, _uniq @export_funcs]); 
    170184  } 
    171185} 
     
    207221  my $all_improt = 0; 
    208222  if (@$org_args) { 
    209     @$org_args = %{$org_args->[0]} if ref $org_args->[0] eq 'HASH'; 
     223    @$org_args = %{$org_args->[0]} if ref $org_args->[0] and (ref $org_args->[0]) eq 'HASH'; 
     224    $opt->{'plugin'} ||= ''; 
    210225    if (lc($org_args->[0]) =~ /^([:-])?all/) { 
    211226      my $all_import = shift @$org_args; 
     
    228243      $pkg->_lazy_load_plugins($config, $org_args); 
    229244    } 
    230     if (List::MoreUtils::any {ref $_} @$org_args) { 
     245    if (_any {ref $_} @$org_args) { 
    231246      for (my $i = 0; $i < @$org_args; $i++) { 
    232247        my $kind = $org_args->[$i]; 
    233         my $import_setting = $org_args->[$i + 1] ? $org_args->[++$i] : undef; 
     248        my $import_setting = ref $org_args->[$i + 1] ? $org_args->[++$i] : undef; 
    234249        _insert_want_arg($config, $kind, $import_setting, \%want_kind, \@arg); 
    235250      } 
     
    335350      } 
    336351    } 
    337     @wanted_funcs = List::MoreUtils::uniq @wanted_funcs; 
     352    @wanted_funcs = _uniq @wanted_funcs; 
    338353  } 
    339354  return \@wanted_funcs, \%local_definition, $kind_prefix || '', $kind_args || {}; 
     
    392407    } elsif ($flg eq '-pluggable') { 
    393408      # pluggable 
     409      require Module::Pluggable; 
    394410      Module::Pluggable->import(require => 0, search_path => [$caller . '::Plugin'], inner => 0); 
    395411      my @plugins = $pkg->plugins; 
     
    410426=cut 
    411427 
    412 our $VERSION = '0.17'; 
     428our $VERSION = '0.18'; 
    413429 
    414430=head1 SYNOPSIS 
     
    559575 use Util::Yours -net_all; # Plugin::Net and Plugin::Net::* is loaded 
    560576 
    561 C<_all> is special keyword. see "NOTE ABOUT all KEYWORD". 
     577C<_all> is special keyword. see L<"NOTE ABOUT all KEYWORD">. 
    562578 
    563579=item debug => 1/2 
     
    747763B<all> is special keyword, so it has some restriction. 
    748764 
    749 =head2 use module with 'all' cannot take any sequential arugments 
     765=head2 use module with 'all' cannot take its arugments 
    750766 
    751767 use Util::Any -all; # or 'all', ':all' 
    752768 
    753 This cannot take sequential arguments. For example; 
     769This cannot take sequential arguments for "all". For example; 
    754770 
    755771 NG: use Util::Any -all => ['shuffle']; 
    756772 
    757 =head2 -plugin_module_all cannot take any sequential arguments 
     773When sequential arguments is kind's, it's ok. 
     774 
     775 use Util::Any -all, -list => ['unique']; 
     776 
     777=head2 -plugin_module_all cannot take its arguments 
    758778 
    759779 use Util::Yours -plugin_name_all; 
    760780 
    761 This cannot take sequential arguments. For example: 
     781This cannot take sequential arguments for it. For example: 
    762782 
    763783 NG: use Util::Yours -plugin_name_all => ['some_function']; 
     
    12451265=head1 COPYRIGHT & LICENSE 
    12461266 
    1247 Copyright 2008-2009 Ktat, all rights reserved. 
     1267Copyright 2008-2010 Ktat, all rights reserved. 
    12481268 
    12491269This program is free software; you can redistribute it and/or modify it 
  • lang/perl/Util-Any/trunk/t/01-util.t

    r35387 r36328  
    3737              [ [ scalar => {-prefix => 'sc_'}], {} ], 
    3838              [ [], {scalar => {-prefix => 'sc_'}} ], 
     39             ], 
     40             [ 
     41              [ ['string', list => ['any', 'uniq']], {} ], 
     42              [ [], {string => undef, list => ['any', 'uniq']} ], 
    3943             ], 
    4044            );