Package-Constants-0.06/000755 001751 001751 00000000000 12446504765 015567 5ustar00bingosbingos000000 000000 Package-Constants-0.06/t/000755 001751 001751 00000000000 12446504765 016032 5ustar00bingosbingos000000 000000 Package-Constants-0.06/lib/000755 001751 001751 00000000000 12446504765 016335 5ustar00bingosbingos000000 000000 Package-Constants-0.06/Makefile.PL000644 001751 001751 00000003320 12446504550 017527 0ustar00bingosbingos000000 000000 use ExtUtils::MakeMaker; use strict; WriteMakefile1( LICENSE => 'perl', META_MERGE => { resources => { repository => 'git://github.com/jib/package-constants.git', }, }, NAME => 'Package::Constants', VERSION_FROM => 'lib/Package/Constants.pm', # finds $VERSION dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' }, PREREQ_PM => { 'Test::More' => 0, }, INSTALLDIRS => ( $] >= 5.009005 && $] < 5.012 ? 'perl' : 'site' ), AUTHOR => 'Jos Boumans ', ABSTRACT => 'List constants defined in a package', MIN_PERL_VERSION => '5.006', ); sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade. my %params=@_; my $eumm_version=$ExtUtils::MakeMaker::VERSION; $eumm_version=eval $eumm_version; die "EXTRA_META is deprecated" if exists $params{EXTRA_META}; die "License not specified" if not exists $params{LICENSE}; if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) { #EUMM 6.5502 has problems with BUILD_REQUIRES $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} }; delete $params{BUILD_REQUIRES}; } delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52; delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48; delete $params{META_MERGE} if $eumm_version < 6.46; delete $params{META_ADD} if $eumm_version < 6.46; delete $params{LICENSE} if $eumm_version < 6.31; delete $params{AUTHOR} if $] < 5.005; delete $params{ABSTRACT_FROM} if $] < 5.005; delete $params{BINARY_LOCATION} if $] < 5.005; WriteMakefile(%params); } Package-Constants-0.06/CHANGES000644 001751 001751 00000001341 12446504665 016560 0ustar00bingosbingos000000 000000 Revision history for Perl module Package::Constants 0.06 2014-12-24 BINGOS - Added min perl version 5.006 to the code, and added "use warnings", and use of our. - Added min perl version 5.006 to metadata - Reformatted this file as per CPAN::Changes::Spec - Added SEE ALSO section to doc 0.04 2013-10-24 BINGOS - Update Makefile.PL to add repository et al - Install into site if >= v5.12.0 - Add use deprecate due to core scheduled removal 0.02 2008-12-13 KANE - Users of 0.01 need not upgrade - Package::Constants is a core module, so the Makefile.PL should reflect this and install into the 'core' directory, instead of 'site' 0.01 2005-09-06 KANE - First release to CPAN Package-Constants-0.06/MANIFEST000644 001751 001751 00000000406 12446504765 016720 0ustar00bingosbingos000000 000000 CHANGES lib/Package/Constants.pm Makefile.PL MANIFEST This list of files README t/01_list.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Package-Constants-0.06/README000644 001751 001751 00000002124 12232272172 016431 0ustar00bingosbingos000000 000000 This is the README file for Package::Constants, a module that lets you list all constants defined in a package. Please refer to 'perldoc Package::Constants' after installation for details. ##################################################################### * Description Package::Constants Package::Constants lists all the constants defined in a certain package. This can be useful for, among others, setting up an autogenerated @EXPORT/@EXPORT_OK for a Constants.pm file. ##################################################################### * Installation Package::Constants follows the standard perl module install process perl Makefile.PL make make test make install The module uses no C or XS parts, so no c-compiler is required. ###################################################################### AUTHOR This module by Jos Boumans . COPYRIGHT This module is copyright (c) 2005 Jos Boumans . All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. Package-Constants-0.06/META.yml000644 001751 001751 00000001120 12446504765 017032 0ustar00bingosbingos000000 000000 --- abstract: 'List constants defined in a package' author: - 'Jos Boumans ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Package-Constants no_index: directory: - t - inc requires: Test::More: '0' perl: '5.006' resources: repository: git://github.com/jib/package-constants.git version: '0.06' Package-Constants-0.06/META.json000644 001751 001751 00000002012 12446504765 017203 0ustar00bingosbingos000000 000000 { "abstract" : "List constants defined in a package", "author" : [ "Jos Boumans " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Package-Constants", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Test::More" : "0", "perl" : "5.006" } } }, "release_status" : "stable", "resources" : { "repository" : { "url" : "git://github.com/jib/package-constants.git" } }, "version" : "0.06" } Package-Constants-0.06/lib/Package/000755 001751 001751 00000000000 12446504765 017670 5ustar00bingosbingos000000 000000 Package-Constants-0.06/lib/Package/Constants.pm000644 001751 001751 00000004605 12446504707 022203 0ustar00bingosbingos000000 000000 package Package::Constants; use if $] >= 5.019006, 'deprecate'; use 5.006; use strict; use warnings; our $VERSION = '0.06'; our $DEBUG = 0; =head1 NAME Package::Constants - List all constants declared in a package =head1 SYNOPSIS use Package::Constants; ### list the names of all constants in a given package; @const = Package::Constants->list( __PACKAGE__ ); @const = Package::Constants->list( 'main' ); ### enable debugging output $Package::Constants::DEBUG = 1; =head1 DESCRIPTION C lists all the constants defined in a certain package. This can be useful for, among others, setting up an autogenerated C<@EXPORT/@EXPORT_OK> for a Constants.pm file. =head1 CLASS METHODS =head2 @const = Package::Constants->list( PACKAGE_NAME ); Lists the names of all the constants defined in the provided package. =cut sub list { my $class = shift; my $pkg = shift; return unless defined $pkg; # some joker might use '0' as a pkg... _debug("Inspecting package '$pkg'"); my @rv; { no strict 'refs'; my $stash = $pkg . '::'; for my $name (sort keys %$stash ) { _debug( " Checking stash entry '$name'" ); ### is it a subentry? my $sub = $pkg->can( $name ); next unless defined $sub; _debug( " '$name' is a coderef" ); next unless defined prototype($sub) and not length prototype($sub); _debug( " '$name' is a constant" ); push @rv, $name; } } return sort @rv; } =head1 GLOBAL VARIABLES =head2 $Package::Constants::DEBUG When set to true, prints out debug information to STDERR about the package it is inspecting. Helps to identify issues when the results are not as you expect. Defaults to false. =cut sub _debug { warn "@_\n" if $DEBUG; } 1; =head1 SEE ALSO L - get a list of all the public functions defined in a package. =head1 BUG REPORTS Please report bugs or other issues to Ebug-package-constants@rt.cpan.org. =head1 AUTHOR This module by Jos Boumans Ekane@cpan.orgE. =head1 COPYRIGHT This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. =cut # Local variables: # c-indentation-style: bsd # c-basic-offset: 4 # indent-tabs-mode: nil # End: # vim: expandtab shiftwidth=4: Package-Constants-0.06/t/01_list.t000644 001751 001751 00000002054 12232272172 017456 0ustar00bingosbingos000000 000000 use strict; use Test::More 'no_plan'; BEGIN { chdir 't' if -d 't' }; use lib '../lib'; my $Class = 'Package::Constants'; my $Func = 'list'; my $Pkg = '_test'; my @Good = 'A'..'C'; my @Bad = 'D'..'E'; use_ok( $Class ); can_ok( $Class, $Func ); ### enable debug statements? $Package::Constants::DEBUG = $Package::Constants::DEBUG = @ARGV ? 1 : 0; ### small test class { package _test; ### mark us as loaded $INC{'_test.pm'} = $0; use vars qw[$FOO]; $FOO = 1; ### define various subs.. the first 3 are constants, ### the others are not use constant A => 1; use constant B => sub { 1 }; sub C () { 1 }; sub D { 1 }; sub E (*) { 1 }; } ### get the list { my @list = $Class->$Func( $Pkg ); ok( scalar(@list), "Got a list of constants" ); is_deeply( \@list, \@Good, " Contains all expected entries" ); } # Local variables: # c-indentation-style: bsd # c-basic-offset: 4 # indent-tabs-mode: nil # End: # vim: expandtab shiftwidth=4: