- Timestamp:
- 01/01/10 06:24:41 (3 years ago)
- Location:
- lang/perl/Util-Any/trunk
- Files:
-
- 3 modified
-
Changes (modified) (2 diffs)
-
lib/Util/Any.pm (modified) (11 diffs)
-
t/01-util.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Util-Any/trunk/Changes
r35510 r36328 1 1 Revision history for Util-Any 2 3 0.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. 2 6 3 7 0.17 2009/10/06 03:32 … … 5 9 enable to work -all with kind setting. for example 6 10 -all, -list => {...} 7 fix typo: inherit Perl6::Exp rot::Attr and ':ALL' keyword didn't work correctly.8 fix typo: inherit Exp roer 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. 9 13 Thanks to Richard Jelinek, again. 10 14 -
lang/perl/Util-Any/trunk/lib/Util/Any.pm
r35510 r36328 4 4 use Clone (); 5 5 use Carp (); 6 use List::MoreUtils ();7 use Module::Pluggable ();8 6 use warnings; 9 7 use strict; … … 21 19 22 20 our $SubExporterImport = 'do_import'; 21 22 # borrow from List::MoreUtils 23 sub _any (&@) { 24 my $f = shift; 25 return if ! @_; 26 for (@_) { 27 return 1 if $f->(); 28 } 29 return 0; 30 } 31 32 sub _uniq (@) { 33 my %h; 34 map { $h{$_}++ == 0 ? $_ : () } @_; 35 } 36 # /end 23 37 24 38 sub import { … … 167 181 } 168 182 } else { 169 ExportTo::export_to($caller => [map $class . '::' . $_, List::MoreUtils::uniq @export_funcs]);183 ExportTo::export_to($caller => [map $class . '::' . $_, _uniq @export_funcs]); 170 184 } 171 185 } … … 207 221 my $all_improt = 0; 208 222 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'} ||= ''; 210 225 if (lc($org_args->[0]) =~ /^([:-])?all/) { 211 226 my $all_import = shift @$org_args; … … 228 243 $pkg->_lazy_load_plugins($config, $org_args); 229 244 } 230 if ( List::MoreUtils::any {ref $_} @$org_args) {245 if (_any {ref $_} @$org_args) { 231 246 for (my $i = 0; $i < @$org_args; $i++) { 232 247 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; 234 249 _insert_want_arg($config, $kind, $import_setting, \%want_kind, \@arg); 235 250 } … … 335 350 } 336 351 } 337 @wanted_funcs = List::MoreUtils::uniq @wanted_funcs;352 @wanted_funcs = _uniq @wanted_funcs; 338 353 } 339 354 return \@wanted_funcs, \%local_definition, $kind_prefix || '', $kind_args || {}; … … 392 407 } elsif ($flg eq '-pluggable') { 393 408 # pluggable 409 require Module::Pluggable; 394 410 Module::Pluggable->import(require => 0, search_path => [$caller . '::Plugin'], inner => 0); 395 411 my @plugins = $pkg->plugins; … … 410 426 =cut 411 427 412 our $VERSION = '0.1 7';428 our $VERSION = '0.18'; 413 429 414 430 =head1 SYNOPSIS … … 559 575 use Util::Yours -net_all; # Plugin::Net and Plugin::Net::* is loaded 560 576 561 C<_all> is special keyword. see "NOTE ABOUT all KEYWORD".577 C<_all> is special keyword. see L<"NOTE ABOUT all KEYWORD">. 562 578 563 579 =item debug => 1/2 … … 747 763 B<all> is special keyword, so it has some restriction. 748 764 749 =head2 use module with 'all' cannot take any sequentialarugments765 =head2 use module with 'all' cannot take its arugments 750 766 751 767 use Util::Any -all; # or 'all', ':all' 752 768 753 This cannot take sequential arguments . For example;769 This cannot take sequential arguments for "all". For example; 754 770 755 771 NG: use Util::Any -all => ['shuffle']; 756 772 757 =head2 -plugin_module_all cannot take any sequential arguments 773 When 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 758 778 759 779 use Util::Yours -plugin_name_all; 760 780 761 This cannot take sequential arguments . For example:781 This cannot take sequential arguments for it. For example: 762 782 763 783 NG: use Util::Yours -plugin_name_all => ['some_function']; … … 1245 1265 =head1 COPYRIGHT & LICENSE 1246 1266 1247 Copyright 2008-20 09Ktat, all rights reserved.1267 Copyright 2008-2010 Ktat, all rights reserved. 1248 1268 1249 1269 This program is free software; you can redistribute it and/or modify it -
lang/perl/Util-Any/trunk/t/01-util.t
r35387 r36328 37 37 [ [ scalar => {-prefix => 'sc_'}], {} ], 38 38 [ [], {scalar => {-prefix => 'sc_'}} ], 39 ], 40 [ 41 [ ['string', list => ['any', 'uniq']], {} ], 42 [ [], {string => undef, list => ['any', 'uniq']} ], 39 43 ], 40 44 );
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)