UNIVERSAL-exports-0.05/0000755000076500007650000000000010476647537014451 5ustar schwernschwernUNIVERSAL-exports-0.05/Changes0000644000076500007650000000137310476647371015744 0ustar schwernschwern0.05 Sun Sep 3 17:52:06 EDT 2006 - Convert tests from ancient ad-hoc to Test::More. - Turn on strictyness. 0.04 Sun Sep 3 17:31:46 EDT 2006 - Removed UNIVERSAL::require from distribution. It is now in its own distribution. - Added copyright and license info - Added link to rt.cpan.org for tracking. - Added extended SEE ALSO to other Exporter-like things. 0.03 Sun Dec 16 21:51:58 EST 2001 - Moved UNIVERSAL::exports import functionality to Exporter::Lite - Fixed a little nit when "use UNIVERSAL" is involved. 0.02 Mon Jun 25 15:00:19 EDT 2001 * -->API CHANGE!<-- require() no longer dies on failure 0.01 Mon Jan 22 11:06:50 EST 2001 * First version, adapted from the Perl 6 RFC prototypes 253 and 257. UNIVERSAL-exports-0.05/lib/0000755000076500007650000000000010476647537015217 5ustar schwernschwernUNIVERSAL-exports-0.05/lib/UNIVERSAL/0000755000076500007650000000000010476647537016567 5ustar schwernschwernUNIVERSAL-exports-0.05/lib/UNIVERSAL/exports.pm0000644000076500007650000000512010476646451020621 0ustar schwernschwernpackage UNIVERSAL::exports; $UNIVERSAL::exports::VERSION = '0.05'; package UNIVERSAL; use strict; use Exporter::Lite qw(import); =head1 NAME UNIVERSAL::exports - Lightweight, universal exporting of variables =head1 SYNOPSIS package Foo; use UNIVERSAL::exports; # Just like Exporter. @EXPORT = qw($This &That); @EXPORT_OK = qw(@Left %Right); # Meanwhile, in another piece of code! package Bar; use Foo; # exports $This and &That. =head1 DESCRIPTION This is an alternative to Exporter intended to provide a universal, lightweight subset of its functionality. It uses Exporter::Lite, so look there for details. Additionally, C is provided to find out what symbols a module exports. UNIVERSAL::exports places its methods in the UNIVERSAL namespace, so there is no need to subclass from it. =head1 Methods UNIVERSAL::exports has two public methods, import() derived from Exporter::Lite, and exports(). =over 4 =item B Some::Module->import; Some::Module->import(@symbols); This is Exporter::Lite's import() method. Look in L for details. =item B @exported_symbols = Some::Module->exports; Some::Module->exports($symbol); Reports what symbols are exported by Some::Module. With no arguments, it simply returns a list of all exportable symbols. Otherwise, it reports if it will export a given $symbol. =cut sub exports { my($exporter) = shift; my %exports; { no strict 'refs'; %exports = map { $_ => 1 } @{$exporter.'::EXPORT'}, @{$exporter.'::EXPORT_OK'}; } if( @_ ) { return exists $exports{$_[0]}; } else { return keys %exports; } } =back =head1 DIAGNOSTICS =over 4 =item '"%s" is not exported by the %s module' Attempted to import a symbol which is not in @EXPORT or @EXPORT_OK. =item 'Can\'t export symbol: %s' Attempted to import a symbol of an unknown type (ie. the leading $@% salad wasn't recognized). =back =head1 AUTHORS Michael G Schwern =head1 BUGS and ISSUES Please report bugs and issues via L =head1 LICENSE and COPYRIGHT Copyright 2001, 2006 Michael G Schwern This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =head1 SEE ALSO Other ways to Export: L, L, L, L The Perl 6 RFC that started it all: L More UNIVERSAL magic: L =cut 007; UNIVERSAL-exports-0.05/Makefile.PL0000644000076500007650000000334610476643170016416 0ustar schwernschwern# A template for Makefile.PL. # - Set the $PACKAGE variable to the name of your module. # - Set $LAST_API_CHANGE to reflect the last version you changed the API # of your module. # - Fill in your dependencies in PREREQ_PM # Alternatively, you can say the hell with this and use h2xs. use ExtUtils::MakeMaker; $PACKAGE = 'UNIVERSAL::exports'; ($PACKAGE_FILE = $PACKAGE) =~ s|::|/|g; $LAST_API_CHANGE = 0.02; eval "require $PACKAGE"; unless ($@) { # Make sure we did find the module. print <<"CHANGE_WARN" if ${$PACKAGE.'::VERSION'} < $LAST_API_CHANGE; NOTE: There have been API changes between this version and any older than version $LAST_API_CHANGE! Please read the Changes file if you are upgrading from a version older than $LAST_API_CHANGE. CHANGE_WARN } WriteMakefile( NAME => $PACKAGE, VERSION_FROM => "lib/$PACKAGE_FILE.pm", # finds $VERSION PREREQ_PM => { Exporter::Lite => 0.01, Test::More => 0.47, }, 'dist' => { COMPRESS => 'gzip -9', SUFFIX => '.gz', DIST_DEFAULT => 'all tardist', }, ); { package MY; sub test_via_harness { my($self, $orig_perl, $tests) = @_; my @perls = ($orig_perl); push @perls, qw(bleadperl perl5.6.1 perl5.6.0 perl5.005_03 perl5.004_05 perl5.004_04 perl5.004) if $ENV{PERL_TEST_ALL}; my $out; foreach my $perl (@perls) { $out .= $self->SUPER::test_via_harness($perl, $tests); } return $out; } } UNIVERSAL-exports-0.05/MANIFEST0000644000076500007650000000026110476647537015601 0ustar schwernschwernChanges lib/UNIVERSAL/exports.pm Makefile.PL MANIFEST This list of files t/Dummy.pm t/exports.t META.yml Module meta-data (added by MakeMaker) UNIVERSAL-exports-0.05/META.yml0000664000076500007650000000065210476647537015727 0ustar schwernschwern--- #YAML:1.0 name: UNIVERSAL-exports version: 0.05 abstract: ~ license: unknown generated_by: ExtUtils::MakeMaker version 6.30_03 author: ~ distribution_type: module requires: Exporter::Lite: 0.01 Test::More: 0.47 meta-spec: url: http://module-build.sourceforge.net/META-spec-new.html version: 1.1 UNIVERSAL-exports-0.05/t/0000755000076500007650000000000010476647537014714 5ustar schwernschwernUNIVERSAL-exports-0.05/t/Dummy.pm0000644000076500007650000000022610476643170016332 0ustar schwernschwernpackage Dummy; @EXPORT = qw(foo); @EXPORT_OK = qw(bar); $VERSION = 0.5; sub foo { 42 } sub bar { 23 } sub car { "yarblockos" } return 23; UNIVERSAL-exports-0.05/t/exports.t0000644000076500007650000000160610476647174016605 0ustar schwernschwern#!/usr/bin/perl -w use strict; use Test::More tests => 16; BEGIN { use_ok 'UNIVERSAL::exports' } use lib qw(t); package Test1; use Dummy; ::ok( defined &foo ); ::is( foo, 42 ); package YATest1; use Dummy qw(foo); ::ok( defined &foo ); ::is( foo, 42 ); package Test2; use Dummy (); ::ok( !defined &foo ); package Test3; eval { Dummy->import('car') }; ::like( $@, '/"car" is not exported by the Dummy module/' ); package Test4; use Dummy qw(bar); ::ok( defined &bar and !defined &foo ); ::is( bar, 23 ); # Test UNIVERSAL::exports() ::is_deeply( [sort Dummy->exports], [sort qw(foo bar)] ); ::ok( Dummy->exports('foo') ); ::ok( Dummy->exports('bar') ); ::ok( !Dummy->exports('car') ); ::ok( !Dummy->exports(007) ); package Test5; use Dummy 0.5; ::pass; # if we don't explode, we're ok. eval "use Dummy 99"; ::like($@, '/Dummy version 99 required--this is only version/');