| 1 | package FindApp::Utils; | ||
| 2 | |||
| 3 | use v5.10; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use Exporter qw(import); | ||
| 8 | our %EXPORT_TAGS; | ||
| 9 | |||
| 10 | use FindApp::Utils::List qw(uniq); | ||
| 11 | use FindApp::Utils::Package qw(PACKAGE); | ||
| 12 | use FindApp::Utils::Paths qw(basename_noext dir_file_ext); | ||
| 13 | |||
| 14 | my $submod_glob; { | ||
| 15 | my($dir, $file, $ext) = dir_file_ext $INC{PACKAGE->pmpath}; | ||
| 16 | $submod_glob = "$dir$file/*$ext"; | ||
| 17 | } | ||
| 18 | |||
| 19 | for my $tail (map { basename_noext } glob $submod_glob) { | ||
| 20 | my $module = PACKAGE->add($tail); | ||
| 21 | eval qq{use $module ':all'; 1} || die; | ||
| 22 | my $his_tags = $module->add("EXPORT_TAGS")->unbless; | ||
| 23 | no strict "refs"; | ||
| 24 | while (my($sub_tag, $aref) = each %$his_tags) { | ||
| 25 | next if $sub_tag eq "all"; | ||
| 26 | if ($EXPORT_TAGS{$sub_tag}) { | ||
| 27 | warn "ignoring duplicate export tag $sub_tag from $module"; | ||
| 28 | next; | ||
| 29 | } | ||
| 30 | $EXPORT_TAGS{$sub_tag} = $aref; | ||
| 31 | } | ||
| 32 | $EXPORT_TAGS{lc $tail} = $his_tags->{all}; | ||
| 33 | } | ||
| 34 | |||
| 35 | our @EXPORT_OK = uniq sort map { @$_ } values %EXPORT_TAGS; | ||
| 36 | |||
| 37 | $EXPORT_TAGS{all} = \@EXPORT_OK; | ||
| 38 | |||
| 39 | 1; | ||
| 40 | |||
| 41 | =encoding utf8 | ||
| 42 | |||
| 43 | =head1 NAME | ||
| 44 | |||
| 45 | FindApp::Utils - FIXME | ||
| 46 | |||
| 47 | =head1 SYNOPSIS | ||
| 48 | |||
| 49 | use FindApp::Utils; | ||
| 50 | |||
| 51 | =head1 DESCRIPTION | ||
| 52 | |||
| 53 | =head2 Public Methods | ||
| 54 | |||
| 55 | =over | ||
| 56 | |||
| 57 | =item FIXME | ||
| 58 | |||
| 59 | =back | ||
| 60 | |||
| 61 | =head2 Exports | ||
| 62 | |||
| 63 | =over | ||
| 64 | |||
| 65 | =item FIXME | ||
| 66 | |||
| 67 | =back | ||
| 68 | |||
| 69 | =head1 EXAMPLES | ||
| 70 | |||
| 71 | =head1 ENVIRONMENT | ||
| 72 | |||
| 73 | =head1 SEE ALSO | ||
| 74 | |||
| 75 | =over | ||
| 76 | |||
| 77 | =item L<FindApp> | ||
| 78 | |||
| 79 | =back | ||
| 80 | |||
| 81 | =head1 CAVEATS AND PROVISOS | ||
| 82 | |||
| 83 | =head1 BUGS AND LIMITATIONS | ||
| 84 | |||
| 85 | =head1 HISTORY | ||
| 86 | |||
| 87 | =head1 AUTHOR | ||
| 88 | |||
| 89 | Tom Christiansen << <tchrist@perl.com> >> | ||
| 90 | |||
| 91 | =head1 LICENCE AND COPYRIGHT | ||
| 92 | |||
| 93 | Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>. | ||
| 94 | All Rights Reserved. | ||
| 95 | |||
| 96 | This module is free software; you can redistribute it and/or | ||
| 97 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||
| 98 | |||
| 99 | =cut | ||
| 100 |