Module-Functions

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - fixed test protability

2.1.0 2013-02-16T11:37:28

    - Added get_full_functions()
      (bayashi)

2.0.0 2013-02-09T12:54:37

    - better docs
    - hide INIT,UNITCHECK,import from public methods.

1.0.0 2013-02-07T13:42:10
    - original version

README.md  view on Meta::CPAN

    sub foo { }

In this case, return value of `get_public_functions('Foo')` does not contain 'catfile'. Return value is `('foo')`.

### RULES

This `get_public_functions` removes some function names.

Rules are here:

- BEGIN, UNITCHECK, CHECK, INIT, and END are hidden.
- 'import' method is hidden
- function name prefixed by '\_' is hidden.

## my @functions = get\_full\_functions();

## my @functions = get\_full\_functions($package)

This function get ALL functions.
ALL means functions that were imported from other packages.
And included specially named functions(BEGIN , UNITCHECK , CHECK , INIT and END).
Of course, included also private functions( ex. \_foo ).

# AUTHOR

Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>

# SEE ALSO

[Exporter::Auto](http://search.cpan.org/perldoc?Exporter::Auto) have same feature of this module, but it stands on very tricky thing.

lib/Module/Functions.pm  view on Meta::CPAN


our @EXPORT = qw(get_public_functions);
our @EXPORT_OK = qw(get_full_functions);

sub get_public_functions {
    my $klass = shift || caller(0);
    my @functions;
    no strict 'refs';
    my %class = %{"${klass}::"};
    while (my ($k, $v) = each %class) {
        next if $k =~ /^(?:BEGIN|UNITCHECK|INIT|CHECK|END|import)$/;
        next if $k =~ /^_/;
        next unless *{"${klass}::${k}"}{CODE};
        next if $klass ne Sub::Identify::stash_name( $klass->can($k) );
        push @functions, $k;
    }
    return @functions;
}

sub get_full_functions {
    my $klass = shift || caller(0);

lib/Module/Functions.pm  view on Meta::CPAN

In this case, return value of C<< get_public_functions('Foo') >> does not contain 'catfile'. Return value is C<< ('foo') >>.

=head3 RULES

This C<< get_public_functions >> removes some function names.

Rules are here:

=over 4

=item BEGIN, UNITCHECK, CHECK, INIT, and END are hidden.

=item 'import' method is hidden

=item function name prefixed by '_' is hidden.

=back

=head2 my @functions = get_full_functions();

=head2 my @functions = get_full_functions($package)

This function get ALL functions.
ALL means functions that were imported from other packages.
And included specially named functions(BEGIN , UNITCHECK , CHECK , INIT and END).
Of course, included also private functions( ex. _foo ).

=head1 AUTHOR

Tokuhiro Matsuno E<lt>tokuhirom AAJKLFJEF@ GMAIL COME<gt>

=head1 SEE ALSO

L<Exporter::Auto> have same feature of this module, but it stands on very tricky thing.



( run in 0.322 second using v1.01-cache-2.11-cpan-748bfb374f4 )