Class-Load-0.20/0000755000175000017500000000000012000631664013213 5ustar autarchautarchClass-Load-0.20/MANIFEST0000644000175000017500000000165012000631664014346 0ustar autarchautarchChanges INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Class/Load.pm lib/Class/Load/PP.pm t/000-load.t t/001-is-class-loaded.t t/002-try-load-class.t t/003-load-class.t t/004-load-double.t t/005-load-optional.t t/006-returned-error.t t/007-first-existing.t t/008-gvstash-bug.t t/009-invalid-module-name.t t/010-isa-false-positive.t t/011-without-xs.t t/012-without-implementation.t t/013-errors.t t/lib/Class/Load/Error/DieAfterBeginIsa.pm t/lib/Class/Load/Error/DieAfterIsa.pm t/lib/Class/Load/Error/SyntaxErrorAfterIsa.pm t/lib/Class/Load/OK.pm t/lib/Class/Load/Stash.pm t/lib/Class/Load/Stash/Sub.pm t/lib/Class/Load/SyntaxError.pm t/lib/Class/Load/VersionCheck.pm t/lib/Class/Load/VersionCheck2.pm t/lib/Test/Class/Load.pm t/release-cpan-changes.t t/release-eol.t t/release-no-tabs.t t/release-pod-coverage.t t/release-pod-linkcheck.t t/release-pod-no404s.t t/release-pod-spell.t t/release-pod-syntax.t Class-Load-0.20/t/0000755000175000017500000000000012000631664013456 5ustar autarchautarchClass-Load-0.20/t/release-pod-spell.t0000644000175000017500000000126612000631664017165 0ustar autarchautarch BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::Spelling; my @stopwords; for () { chomp; push @stopwords, $_ unless /\A (?: \# | \s* \z)/msx; } add_stopwords(@stopwords); set_spell_cmd('aspell list -l en'); # This prevents a weird segfault from the aspell command - see # https://bugs.launchpad.net/ubuntu/+source/aspell/+bug/71322 local $ENV{LC_ALL} = 'C'; all_pod_files_spelling_ok; __DATA__ API Bcc cid CPAN Courriel DateTime html Multipart PayPal Rolsky UTC ascii attribute's distro filename inline multipart utf UTF Class-Load-0.20/t/012-without-implementation.t0000644000175000017500000000072612000631664020676 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use Test::Fatal; use Test::Requires { 'Test::Without::Module' => 0, }; use Test::Without::Module qw( Class::Load::PP Class::Load::XS ); { like( exception { require Class::Load }, qr/Class.Load.PP\.pm did not return a true value/, 'error when loading Class::Load and no implementation is available includes errors from trying to load modules' ); } done_testing(); Class-Load-0.20/t/lib/0000755000175000017500000000000012000631664014224 5ustar autarchautarchClass-Load-0.20/t/lib/Class/0000755000175000017500000000000012000631664015271 5ustar autarchautarchClass-Load-0.20/t/lib/Class/Load/0000755000175000017500000000000012000631664016150 5ustar autarchautarchClass-Load-0.20/t/lib/Class/Load/Error/0000755000175000017500000000000012000631664017241 5ustar autarchautarchClass-Load-0.20/t/lib/Class/Load/Error/DieAfterIsa.pm0000644000175000017500000000045512000631664021723 0ustar autarchautarchpackage Class::Load::Error::DieAfterIsa; use strict; use warnings; # This library emulates a bug that can occur under App::Cmd, # # A broken library use's another library ( App::Cmd::Setup ), and that library # injects @ISA during import->() our @ISA = qw( UNIVERSAL ); die "Not a syntax error"; Class-Load-0.20/t/lib/Class/Load/Error/DieAfterBeginIsa.pm0000644000175000017500000000022012000631664022656 0ustar autarchautarchpackage Class::Load::Error::DieAfterBeginIsa; use strict; use warnings; BEGIN { our @ISA = qw( UNIVERSAL ); } die "Not a syntax error"; Class-Load-0.20/t/lib/Class/Load/Error/SyntaxErrorAfterIsa.pm0000644000175000017500000000044312000631664023517 0ustar autarchautarchpackage Class::Load::Error::SyntaxErrorAfterIsa; use strict; use warnings; # This library emulates a bug that can occur under App::Cmd, # # A Broken library "use"'s annother library ( App::Cmd::Setup ), and # that library injects @ISA during import->() our @ISA = qw( UNIVERSAL ); #} sub { Class-Load-0.20/t/lib/Class/Load/Stash.pm0000644000175000017500000000012712000631664017570 0ustar autarchautarchpackage Class::Load::Stash; use strict; use warnings; sub a_method { 'a_method' } 1; Class-Load-0.20/t/lib/Class/Load/SyntaxError.pm0000644000175000017500000000013012000631664021000 0ustar autarchautarch#!/usr/bin/env perl package Class::Load::SyntaxError; use strict; use warnings; sub { Class-Load-0.20/t/lib/Class/Load/Stash/0000755000175000017500000000000012000631664017232 5ustar autarchautarchClass-Load-0.20/t/lib/Class/Load/Stash/Sub.pm0000644000175000017500000000021612000631664020320 0ustar autarchautarchpackage Class::Load::Stash::Sub; use strict; use warnings; sub ver_test { return "Class::Load::Stash ver $Class::Load::Stash::VERSION" } 1; Class-Load-0.20/t/lib/Class/Load/VersionCheck.pm0000644000175000017500000000017012000631664021067 0ustar autarchautarch#!/usr/bin/env perl package Class::Load::VersionCheck; use strict; use warnings; our $VERSION = 42; sub ok { 1 } 1; Class-Load-0.20/t/lib/Class/Load/VersionCheck2.pm0000644000175000017500000000017112000631664021152 0ustar autarchautarch#!/usr/bin/env perl package Class::Load::VersionCheck2; use strict; use warnings; our $VERSION = 42; sub ok { 1 } 1; Class-Load-0.20/t/lib/Class/Load/OK.pm0000644000175000017500000000013212000631664017013 0ustar autarchautarch#!/usr/bin/env perl package Class::Load::OK; use strict; use warnings; sub ok { 1 } 1; Class-Load-0.20/t/lib/Test/0000755000175000017500000000000012000631664015143 5ustar autarchautarchClass-Load-0.20/t/lib/Test/Class/0000755000175000017500000000000012000631664016210 5ustar autarchautarchClass-Load-0.20/t/lib/Test/Class/Load.pm0000644000175000017500000000033612000631664017427 0ustar autarchautarchpackage # hide from PAUSE Test::Class::Load; use strict; use warnings; use Class::Load::PP; $ENV{CLASS_LOAD_IMPLEMENTATION} = 'PP'; require Class::Load; sub import { Class::Load->export_to_level(1, @_); } 1; Class-Load-0.20/t/008-gvstash-bug.t0000644000175000017500000000106612000631664016405 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::Fatal; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load 'load_class'; is( exception { load_class('Class::Load::Stash::Sub'); }, undef, 'Loaded Class::Load::Stash::Sub' ); Class::Load::Stash->can('a_method'); is( exception { load_class('Class::Load::Stash'); }, undef, 'Loaded Class::Load::Stash' ); is( exception { Class::Load::Stash->a_method; }, undef, 'Actually loaded Class::Load::Stash - we were not fooled by mention of this stash in Class::Load::Stash::Sub' ); done_testing; Class-Load-0.20/t/007-first-existing.t0000644000175000017500000000771612000631664017141 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::Fatal; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load 'load_first_existing_class'; is( load_first_existing_class( 'Class::Load::Nonexistent', 'Class::Load::OK' ), 'Class::Load::OK', 'load_first_existing_class ignore nonexistent class' ); is( load_first_existing_class( 'Class::Load::Nonexistent', 'Class::Load::OK' ), 'Class::Load::OK', 'load_first_existing_class ignore nonexistent class - works when good class is already loaded' ); like( exception { load_first_existing_class( 'Foo', 'bad name' ); }, qr/^\Q`bad name' is not a module name/, 'load_first_existing_class balks on bad class name' ); like( exception { load_first_existing_class( 'Class::Load::Nonexistent', 'Class::Load::Nonexistent2' ); }, qr/^\QCan't locate Class::Load::Nonexistent or Class::Load::Nonexistent2 in \E\@INC/, 'load_first_existing_class throws an error when no classes can be loaded' ); like( exception { load_first_existing_class( 'Class::Load::Nonexistent', 'Class::Load::Nonexistent2', 'Class::Load::Nonexistent3' ); }, qr/^\QCan't locate Class::Load::Nonexistent, Class::Load::Nonexistent2, or Class::Load::Nonexistent3 in \E\@INC/, 'load_first_existing_class throws an error when no classes can be loaded' ); like( exception { load_first_existing_class( 'Class::Load::Nonexistent' ); }, qr/^\QCan't locate Class::Load::Nonexistent in \E\@INC/, 'load_first_existing_class throws an error when given one class which it cannot load' ); like( exception { load_first_existing_class( 'Class::Load::VersionCheck', { -version => 43 }, 'Class::Load::VersionCheck2', { -version => 43 }, ); }, qr/^\QCan't locate Class::Load::VersionCheck (version >= 43) or Class::Load::VersionCheck2 (version >= 43) in \E\@INC/, 'load_first_existing_class throws an error when given multiple classes which it cannot load because of version checks' ); like( exception { load_first_existing_class( 'Class::Load::VersionCheck', { -version => 43 }, 'Class::Load::VersionCheck2', { -version => 43 }, 'Class::Load::Nonexistent' ); }, qr/^\QCan't locate Class::Load::VersionCheck (version >= 43), Class::Load::VersionCheck2 (version >= 43), or Class::Load::Nonexistent in \E\@INC/, 'load_first_existing_class throws an error when given multiple classes which it cannot load, some because of version checks' ); like( exception { load_first_existing_class( 'Class::Load::VersionCheck', {-version => 43} ); }, qr/^\QCan't locate Class::Load::VersionCheck (version >= 43) in \E\@INC/, 'load_first_existing_class throws an error when given one class which it cannot load because of version checks' ); like( exception { load_first_existing_class( 'Class::Load::VersionCheck2', { -version => 43 }, 'Class::Load::SyntaxError', { -version => 43 }, 'Class::Load::Nonexistent' ); }, qr/^\QCouldn't load class (Class::Load::SyntaxError) because: Missing right curly or square bracket/, 'load_first_existing_class throws an error when a class fails to load because of a syntax error' ); is( load_first_existing_class( 'Class::Load::VersionCheck', { -version => 43 }, 'Class::Load::VersionCheck2', { -version => 43 }, 'Class::Load::OK' ), 'Class::Load::OK', 'load_first_existing_class returns loadable class when two classes fail version checks' ); is( load_first_existing_class( 'Class::Load::VersionCheck', { -version => 43 }, 'Class::Load::VersionCheck2', { -version => 41 }, 'Class::Load::OK' ), 'Class::Load::VersionCheck2', 'load_first_existing_class returns loadable class when a class passes the version check' ); done_testing; Class-Load-0.20/t/013-errors.t0000644000175000017500000000522212000631664015461 0ustar autarchautarchuse strict; use warnings; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load ':all'; my $file = __FILE__; { # line 1 eval { load_class('Class::NonExistent') }; my $e = $@; unlike( $e, qr/at .+Load\.pm line \d+/, 'load_class exception does not refer to Class::Load internals' ); unlike( $e, qr/at .+Runtime\.pm line \d+/, 'load_class exception does not refer to Module::Runtime internals' ); like( $e, qr/Can't locate [^\n]+ at \Q$file\E line 1/, 'error appears from the spot that called load_class' ); } { my ( $ok, $e ) = try_load_class('Class::NonExistent::Take2'); unlike( $e, qr/at .+Load\.pm line \d+/, 'try_load_class exception does not refer to Class::Load internals' ); unlike( $e, qr/at .+Runtime\.pm line \d+/, 'try_load_class exception does not refer to Module::Runtime internals' ); } { # line 2 eval { load_first_existing_class('Class::NonExistent::Take3') }; my $e = $@; unlike( $e, qr/at .+Load\.pm line \d+/, 'load_first_existing_class exception does not refer to Class::Load internals' ); unlike( $e, qr/at .+Runtime\.pm line \d+/, 'load_first_existing_class exception does not refer to Module::Runtime internals' ); like( $e, qr/Can't locate [^\n]+ at \Q$file\E line 2/, 'error appears from the spot that called load_first_existing_class' ); } { # line 3 eval { load_first_existing_class('Class::Load::SyntaxError') }; my $e = $@; unlike( $e, qr/at .+Load\.pm line \d+/, 'load_first_existing_class exception does not refer to Class::Load internals' ); unlike( $e, qr/at .+Runtime\.pm line \d+/, 'load_first_existing_class exception does not refer to Module::Runtime internals' ); like( $e, qr/Compilation failed .+? at \Q$file\E line 3/s, 'error appears from the spot that called load_first_existing_class' ); } { # line 4 eval { load_optional_class('Class::Load::SyntaxError') }; my $e = $@; unlike( $e, qr/at .+Load\.pm line \d+/, 'load_optional_class exception does not refer to Class::Load internals' ); unlike( $e, qr/at .+Runtime\.pm line \d+/, 'load_optional_class exception does not refer to Module::Runtime internals' ); like( $e, qr/Compilation failed .+? at \Q$file\E line 4/s, 'error appears from the spot that called load_optional_class' ); } done_testing(); Class-Load-0.20/t/release-no-tabs.t0000644000175000017500000000045012000631664016623 0ustar autarchautarch BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::NoTabs'; plan skip_all => 'Test::NoTabs required' if $@; all_perl_files_ok(); Class-Load-0.20/t/011-without-xs.t0000644000175000017500000000066012000631664016277 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use Test::Fatal; use Test::Requires { 'Test::Without::Module' => 0, }; use Test::Without::Module 'Class::Load::XS'; { my @warnings; local $SIG{__WARN__} = sub { push @warnings, @_ }; require Class::Load; is_deeply( \@warnings, [], 'no warning from Class::Load when Class::Load::XS is not available' ); } done_testing(); Class-Load-0.20/t/002-try-load-class.t0000644000175000017500000000236312000631664017004 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load ':all'; ok(try_load_class('Class::Load::OK'), "loaded class OK"); is($Class::Load::ERROR, undef); ok(!try_load_class('Class::Load::Nonexistent'), "didn't load class Nonexistent"); like($Class::Load::ERROR, qr{^Can't locate Class/Load/Nonexistent.pm in \@INC}); ok(try_load_class('Class::Load::OK'), "loaded class OK"); is($Class::Load::ERROR, undef); ok(!try_load_class('Class::Load::SyntaxError'), "didn't load class SyntaxError"); like($Class::Load::ERROR, qr{^Missing right curly or square bracket at }); ok(is_class_loaded('Class::Load::OK')); ok(!is_class_loaded('Class::Load::Nonexistent')); ok(!is_class_loaded('Class::Load::SyntaxError')); do { package Class::Load::Inlined; sub inlined { 1 } }; ok(try_load_class('Class::Load::Inlined'), "loaded class Inlined"); is($Class::Load::ERROR, undef); ok(is_class_loaded('Class::Load::Inlined')); ok(!try_load_class('Class::Load::VersionCheck', { -version => 43 })); ok(try_load_class('Class::Load::VersionCheck', { -version => 41 })); ok(try_load_class('Class::Load::VersionCheck2', { -version => 41 })); ok(!try_load_class('Class::Load::VersionCheck2', { -version => 43 })); done_testing; Class-Load-0.20/t/005-load-optional.t0000644000175000017500000000172312000631664016712 0ustar autarchautarch use strict; use warnings; use Test::More 0.88; use Test::Fatal; use lib 't/lib'; use Test::Class::Load qw( :all ); is( exception { load_optional_class('Class::Load::OK'); }, undef, 'No failure loading a good class' ); is( exception { load_optional_class('Class::Load::IDONOTEXIST'); }, undef, 'No failure loading a missing class' ); isnt( exception { load_optional_class('Class::Load::SyntaxError'); }, undef, 'Loading a broken class breaks' ); is( load_optional_class('Class::Load::OK'), 1 , 'Existing Class => 1'); is( load_optional_class('Class::Load::IDONOTEXIST'), 0, 'Missing Class => 0'); is( load_optional_class('Class::Load::VersionCheck'), 1, 'VersionCheck => 1'); is( load_optional_class('Class::Load::VersionCheck', {-version => 43}), 0, 'VersionCheck (with too-high version) => 0'); is( load_optional_class('Class::Load::VersionCheck', {-version => 41}), 1, 'VersionCheck (with ok version) => 1'); done_testing; Class-Load-0.20/t/release-pod-linkcheck.t0000644000175000017500000000077512000631664020005 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; foreach my $env_skip ( qw( SKIP_POD_LINKCHECK ) ){ plan skip_all => "\$ENV{$env_skip} is set, skipping" if $ENV{$env_skip}; } eval "use Test::Pod::LinkCheck"; if ( $@ ) { plan skip_all => 'Test::Pod::LinkCheck required for testing POD'; } else { Test::Pod::LinkCheck->new->all_pod_ok; } Class-Load-0.20/t/006-returned-error.t0000644000175000017500000000235212000631664017127 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load ':all'; { ok(try_load_class('Class::Load::OK'), "loaded class OK"); my ($r, $e) = try_load_class('Class::Load::OK'); is($e, undef); } { ok(!try_load_class('Class::Load::Nonexistent'), "didn't load class Nonexistent"); my ($r, $e) = try_load_class('Class::Load::Nonexistent'); like($e, qr{^Can't locate Class/Load/Nonexistent.pm in \@INC}); } { ok(try_load_class('Class::Load::OK'), "loaded class OK"); my ($r, $e) = try_load_class('Class::Load::OK'); is($e, undef); } { ok(!try_load_class('Class::Load::SyntaxError'), "didn't load class SyntaxError"); delete $INC{'Class/Load/SyntaxError.pm'}; my ($r, $e) = try_load_class('Class::Load::SyntaxError'); like($e, qr{^Missing right curly or square bracket at }); } ok(is_class_loaded('Class::Load::OK')); ok(!is_class_loaded('Class::Load::Nonexistent')); ok(!is_class_loaded('Class::Load::SyntaxError')); { $@ = "foo"; ok(try_load_class('Class::Load::OK'), "loaded class OK"); is($@, "foo"); } { $@ = "foo"; ok(!try_load_class('Class::Load::Nonexistent'), "didn't load class Nonexistent"); is($@, "foo"); } done_testing; Class-Load-0.20/t/004-load-double.t0000644000175000017500000000125712000631664016340 0ustar autarchautarchuse strict; use warnings; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load ':all'; use Test::Fatal; # This test does 2 things. # Firstly, confirm that on 5.8, load_class will # still throw an exception , even if its been loaded before: # # eval { require Foo; }; require Foo; # doesn't error on 5.8 # # Secondly, to ensure errors thrown are useful. # ( As without the code in load_class to delete $INC{file} # it will just die with "COMPILATION ERROR", which is # not useful ) # like( exception { load_class('Class::Load::SyntaxError'); }, qr/syntax error/ ); like( exception { load_class('Class::Load::SyntaxError'); }, qr/syntax error/ ); done_testing; Class-Load-0.20/t/release-eol.t0000644000175000017500000000047612000631664016047 0ustar autarchautarch BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::EOL'; plan skip_all => 'Test::EOL required' if $@; all_perl_files_ok({ trailing_whitespace => 1 }); Class-Load-0.20/t/release-pod-syntax.t0000644000175000017500000000045012000631664017366 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); Class-Load-0.20/t/000-load.t0000644000175000017500000000043512000631664015061 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use lib 't/lib'; use Module::Implementation 0.04 (); use_ok 'Test::Class::Load'; diag( 'Using ' . Module::Implementation::implementation_for('Class::Load') . ' implementation' ); done_testing; Class-Load-0.20/t/009-invalid-module-name.t0000644000175000017500000000064712000631664020007 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::Fatal; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load 'load_class'; my @bad = qw( Foo:Bar 123 Foo::..::..::tmp::bad.pl ::..::tmp::bad ''tmp 'tmp ); for my $name (@bad) { like( exception { load_class($name) }, qr/^\Q`$name' is not a module name/, "invalid module name - $name" ); } done_testing; Class-Load-0.20/t/release-pod-no404s.t0000644000175000017500000000076512000631664017100 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; foreach my $env_skip ( qw( SKIP_POD_NO404S AUTOMATED_TESTING ) ){ plan skip_all => "\$ENV{$env_skip} is set, skipping" if $ENV{$env_skip}; } eval "use Test::Pod::No404s"; if ( $@ ) { plan skip_all => 'Test::Pod::No404s required for testing POD'; } else { all_pod_files_ok(); } Class-Load-0.20/t/release-pod-coverage.t0000644000175000017500000000145212000631664017636 0ustar autarchautarch#!/usr/bin/perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; use Test::Requires { 'Test::Pod::Coverage' => '1.04', }; my @modules = 'Class::Load'; my %trustme; for my $module ( sort @modules ) { my $trustme = []; if ( $trustme{$module} ) { if ( ref $trustme{$module} eq 'ARRAY' ) { my $methods = join '|', @{ $trustme{$module} }; $trustme = [qr/^(?:$methods)$/]; } else { $trustme = [ $trustme{$module} ]; } } pod_coverage_ok( $module, { trustme => $trustme, }, "Pod coverage for $module" ); } done_testing(); Class-Load-0.20/t/release-cpan-changes.t0000644000175000017500000000047112000631664017612 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); done_testing(); Class-Load-0.20/t/010-isa-false-positive.t0000644000175000017500000000267512000631664017657 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use Test::Fatal; use lib 't/lib'; use Test::Class::Load 'load_optional_class'; isnt( exception { load_optional_class('Class::Load::Error::DieAfterIsa'); }, undef, 'Class which calls die is reported as an error' ); { local $TODO = q{I'm not sure this is fixable as it's really an interpreter issue.}; isnt( exception { load_optional_class('Class::Load::Error::DieAfterIsa'); }, undef, 'Class which calls die is reported as an error (second attempt)' ); } isnt( exception { load_optional_class('Class::Load::Error::DieAfterBeginIsa'); }, undef, 'Class populates @ISA in BEGIN then dies - error on load' ); { local $TODO = q{I'm not sure this is fixable as it's really an interpreter issue.}; isnt( exception { load_optional_class('Class::Load::Error::DieAfterBeginIsa'); }, undef, 'Class populates @ISA in BEGIN then dies - error on load (second attempt)' ); } isnt( exception { load_optional_class('Class::Load::Error::SyntaxErrorAfterIsa'); }, undef, 'Class with a syntax error causes an error' ); isnt( exception { load_optional_class('Class::Load::Error::SyntaxErrorAfterIsa'); }, undef, 'Class with a syntax error causes an error (second attempt)' ); done_testing; Class-Load-0.20/t/003-load-class.t0000644000175000017500000000442712000631664016174 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use lib 't/lib'; use Test::Class::Load ':all'; use Test::Fatal; is( load_class('Class::Load::OK'), 'Class::Load::OK', 'loaded class OK' ); is( $Class::Load::ERROR, undef, 'ERROR is undef' ); like( exception { load_class('Class::Load::Nonexistent'); }, qr{^Can't locate Class/Load/Nonexistent.pm in \@INC}, 'threw exception for nonexistent class' ); like( $Class::Load::ERROR, qr{^Can't locate Class/Load/Nonexistent.pm in \@INC}, 'ERROR message for nonexistent class', ); ok( load_class('Class::Load::OK'), 'loaded class OK' ); is( $Class::Load::ERROR, undef, 'ERROR is undef' ); like( exception { load_class('Class::Load::SyntaxError'); }, qr{^Missing right curly or square bracket at }, 'exception contains syntax error message' ); like( $Class::Load::ERROR, qr{^Missing right curly or square bracket at }, 'ERROR contains syntax error message' ); ok( is_class_loaded('Class::Load::OK') ); ok( !is_class_loaded('Class::Load::Nonexistent') ); ok( !is_class_loaded('Class::Load::SyntaxError') ); do { package Class::Load::Inlined; sub inlined { 1 } }; is( load_class('Class::Load::Inlined'), 'Class::Load::Inlined', 'loaded class Inlined' ); is( $Class::Load::ERROR, undef ); ok( is_class_loaded('Class::Load::Inlined') ); like( exception { load_class( 'Class::Load::VersionCheck', { -version => 43 } ); }, qr/^Class::Load::VersionCheck version 43 required/, 'got expected error for load_class with explicit version' ); is( load_class( 'Class::Load::VersionCheck', { -version => 41 } ), 'Class::Load::VersionCheck', 'loaded class with version check' ); is( load_class( 'Class::Load::VersionCheck2', { -version => 41 } ), 'Class::Load::VersionCheck2', 'loaded class with version check' ); like( exception { load_class( 'Class::Load::VersionCheck2', { -version => 43 } ); }, qr/^Class::Load::VersionCheck2 version 43 required/, 'got expected error for load_class with explicit version (after class has been loaded into memory)' ); like( exception { load_class('__PACKAGE__'); }, qr/__PACKAGE__\.pm.*\@INC/, 'errors sanely on __PACKAGE__.pm' ); done_testing; Class-Load-0.20/t/001-is-class-loaded.t0000644000175000017500000000622712000631664017114 0ustar autarchautarch#!/usr/bin/env perl use strict; use warnings; use Test::More 0.88; use version; use lib 't/lib'; use Test::Class::Load 'is_class_loaded'; # basic {{{ ok(is_class_loaded('Class::Load'), "Class::Load is loaded"); ok(!is_class_loaded('Class::Load::NONEXISTENT'), "nonexistent class is NOT loaded"); # }}} # @ISA (yes) {{{ do { package Class::Load::WithISA; our @ISA = 'Class::Load'; }; ok(is_class_loaded('Class::Load::WithISA'), "class that defines \@ISA is loaded"); # }}} # $ISA (no) {{{ do { package Class::Load::WithScalarISA; our $ISA = 'Class::Load'; }; ok(!is_class_loaded('Class::Load::WithScalarISA'), "class that defines \$ISA is not loaded"); # }}} # $VERSION (yes) {{{ do { package Class::Load::WithVERSION; our $VERSION = '1.0'; }; ok(is_class_loaded('Class::Load::WithVERSION'), "class that defines \$VERSION is loaded"); # }}} # $VERSION is a version object (yes) {{{ do { package Class::Load::WithVersionObject; our $VERSION = version->new(1); }; ok(is_class_loaded('Class::Load::WithVersionObject'), 'when $VERSION contains a version object, we still return true'); # }}} # method (yes) {{{ do { package Class::Load::WithMethod; sub foo { } }; ok(is_class_loaded('Class::Load::WithMethod'), "class that defines any method is loaded"); # }}} # global scalar (no) {{{ do { package Class::Load::WithScalar; our $FOO = 1; }; ok(!is_class_loaded('Class::Load::WithScalar'), "class that defines just a scalar is not loaded"); # }}} # subpackage (no) {{{ do { package Class::Load::Foo::Bar; sub bar {} }; ok(!is_class_loaded('Class::Load::Foo'), "even if Foo::Bar is loaded, Foo is not"); # }}} # superstring (no) {{{ do { package Class::Load::Quuxquux; sub quux {} }; ok(!is_class_loaded('Class::Load::Quux'), "Quuxquux does not imply the existence of Quux"); # }}} # use constant (yes) {{{ do { package Class::Load::WithConstant; use constant PI => 3; }; ok(is_class_loaded('Class::Load::WithConstant'), "defining a constant means the class is loaded"); # }}} # use constant with reference (yes) {{{ do { package Class::Load::WithRefConstant; use constant PI => \3; }; ok(is_class_loaded('Class::Load::WithRefConstant'), "defining a constant as a reference means the class is loaded"); # }}} # stub (yes) {{{ do { package Class::Load::WithStub; sub foo; }; ok(is_class_loaded('Class::Load::WithStub'), "defining a stub means the class is loaded"); # }}} # stub with prototype (yes) {{{ do { package Class::Load::WithPrototypedStub; sub foo (&); }; ok(is_class_loaded('Class::Load::WithPrototypedStub'), "defining a stub with a prototype means the class is loaded"); # }}} ok(!is_class_loaded('Class::Load::VersionCheck'), 'Class::Load::VersionCheck has not been loaded yet'); require Class::Load::VersionCheck; ok(is_class_loaded('Class::Load::VersionCheck'), 'Class::Load::VersionCheck has been loaded'); ok(!is_class_loaded('Class::Load::VersionCheck', {-version => 43}), 'Class::Load::VersionCheck has been loaded but the version check failed'); ok(is_class_loaded('Class::Load::VersionCheck', {-version => 41}), 'Class::Load::VersionCheck has been loaded and the version check passed'); done_testing; Class-Load-0.20/lib/0000755000175000017500000000000012000631664013761 5ustar autarchautarchClass-Load-0.20/lib/Class/0000755000175000017500000000000012000631664015026 5ustar autarchautarchClass-Load-0.20/lib/Class/Load.pm0000644000175000017500000002305612000631664016251 0ustar autarchautarchpackage Class::Load; { $Class::Load::VERSION = '0.20'; } use strict; use warnings; use base 'Exporter'; use Data::OptList 'mkopt'; use Module::Implementation 0.04; use Module::Runtime 0.012 qw( check_module_name module_notional_filename require_module use_module ); use Try::Tiny; { my $loader = Module::Implementation::build_loader_sub( implementations => [ 'XS', 'PP' ], symbols => ['is_class_loaded'], ); $loader->(); } our @EXPORT_OK = qw/load_class load_optional_class try_load_class is_class_loaded load_first_existing_class/; our %EXPORT_TAGS = ( all => \@EXPORT_OK, ); our $ERROR; sub load_class { my $class = shift; my $options = shift; my ($res, $e) = try_load_class($class, $options); return $class if $res; _croak($e); } sub load_first_existing_class { my $classes = Data::OptList::mkopt(\@_) or return; foreach my $class (@{$classes}) { check_module_name($class->[0]); } for my $class (@{$classes}) { my ($name, $options) = @{$class}; # We need to be careful not to pass an undef $options to this sub, # since the XS version will blow up if that happens. return $name if is_class_loaded($name, ($options ? $options : ())); my ($res, $e) = try_load_class($name, $options); return $name if $res; my $file = module_notional_filename($name); next if $e =~ /^Can't locate \Q$file\E in \@INC/; next if $options && defined $options->{-version} && $e =~ _version_fail_re($name, $options->{-version}); _croak("Couldn't load class ($name) because: $e"); } my @list = map { $_->[0] . ( $_->[1] && defined $_->[1]{-version} ? " (version >= $_->[1]{-version})" : q{} ) } @{$classes}; my $err .= q{Can't locate } . _or_list(@list) . " in \@INC (\@INC contains: @INC)."; _croak($err); } sub _version_fail_re { my $name = shift; my $vers = shift; return qr/\Q$name\E version \Q$vers\E required--this is only version/; } sub _nonexistent_fail_re { my $name = shift; my $file = module_notional_filename($name); return qr/Can't locate \Q$file\E in \@INC/; } sub _or_list { return $_[0] if @_ == 1; return join ' or ', @_ if @_ ==2; my $last = pop; my $list = join ', ', @_; $list .= ', or ' . $last; return $list; } sub load_optional_class { my $class = shift; my $options = shift; check_module_name($class); my ($res, $e) = try_load_class($class, $options); return 1 if $res; return 0 if $options && defined $options->{-version} && $e =~ _version_fail_re($class, $options->{-version}); return 0 if $e =~ _nonexistent_fail_re($class); _croak($e); } sub try_load_class { my $class = shift; my $options = shift; check_module_name($class); local $@; undef $ERROR; if (is_class_loaded($class)) { # We need to check this here rather than in is_class_loaded() because # we want to return the error message for a failed version check, but # is_class_loaded just returns true/false. return 1 unless $options && defined $options->{-version}; return try { $class->VERSION($options->{-version}); 1; } catch { _error($_); }; } my $file = module_notional_filename($class); # This says "our diagnostics of the package # say perl's INC status about the file being loaded are # wrong", so we delete it from %INC, so when we call require(), # perl will *actually* try reloading the file. # # If the file is already in %INC, it won't retry, # And on 5.8, it won't fail either! # # The extra benefit of this trick, is it helps even on # 5.10, as instead of dying with "Compilation failed", # it will die with the actual error, and thats a win-win. delete $INC{$file}; return try { local $SIG{__DIE__} = 'DEFAULT'; if ($options && defined $options->{-version}) { use_module($class, $options->{-version}); } else { require_module($class); } 1; } catch { _error($_); }; } sub _error { my $e = shift; $e =~ s/ at .+?Runtime\.pm line [0-9]+\.$//; chomp $e; $ERROR = $e; return 0 unless wantarray; return 0, $ERROR; } sub _croak { require Carp; local $Carp::CarpLevel = $Carp::CarpLevel + 2; Carp::croak(shift); } 1; # ABSTRACT: a working (require "Class::Name") and more =pod =head1 NAME Class::Load - a working (require "Class::Name") and more =head1 VERSION version 0.20 =head1 SYNOPSIS use Class::Load ':all'; try_load_class('Class::Name') or plan skip_all => "Class::Name required to run these tests"; load_class('Class::Name'); is_class_loaded('Class::Name'); my $baseclass = load_optional_class('Class::Name::MightExist') ? 'Class::Name::MightExist' : 'Class::Name::Default'; =head1 DESCRIPTION C only accepts C style module names, not C. How frustrating! For that, we provide C. It's often useful to test whether a module can be loaded, instead of throwing an error when it's not available. For that, we provide C. Finally, sometimes we need to know whether a particular class has been loaded. Asking C<%INC> is an option, but that will miss inner packages and any class for which the filename does not correspond to the package name. For that, we provide C. =head1 FUNCTIONS =head2 load_class Class::Name, \%options C will load C or throw an error, much like C. If C is already loaded (checked with C) then it will not try to load the class. This is useful when you have inner packages which C does not check. The C<%options> hash currently accepts one key, C<-version>. If you specify a version, then this subroutine will call C<< Class::Name->VERSION( $options{-version} ) >> internally, which will throw an error if the class's version is not equal to or greater than the version you requested. This method will return the name of the class on success. =head2 try_load_class Class::Name, \%options -> (0|1, error message) Returns 1 if the class was loaded, 0 if it was not. If the class was not loaded, the error will be returned as a second return value in list context. Again, if C is already loaded (checked with C) then it will not try to load the class. This is useful when you have inner packages which C does not check. Like C, you can pass a C<-version> in C<%options>. If the version is not sufficient, then this subroutine will return false. =head2 is_class_loaded Class::Name, \%options -> 0|1 This uses a number of heuristics to determine if the class C is loaded. There heuristics were taken from L's old pure-perl implementation. Like C, you can pass a C<-version> in C<%options>. If the version is not sufficient, then this subroutine will return false. =head2 load_first_existing_class Class::Name, \%options, ... This attempts to load the first loadable class in the list of classes given. Each class name can be followed by an options hash reference. If any one of the classes loads and passes the optional version check, that class name will be returned. If I of the classes can be loaded (or none pass their version check), then an error will be thrown. If, when attempting to load a class, it fails to load because of a syntax error, then an error will be thrown immediately. =head2 load_optional_class Class::Name, \%options -> 0|1 C is a lot like C, but also a lot like C. If the class exists, and it works, then it will return 1. If you specify a version in C<%options>, then the version check must succeed or it will return 0. If the class doesn't exist, and it appears to not exist on disk either, it will return 0. If the class exists on disk, but loading from disk results in an error ( i.e.: a syntax error ), then it will C with that error. This is useful for using if you want a fallback module system, i.e.: my $class = load_optional_class($foo) ? $foo : $default; That way, if $foo does exist, but can't be loaded due to error, you won't get the behaviour of it simply not existing. =head1 SEE ALSO =over 4 =item L This blog post is a good overview of the current state of the existing modules for loading other modules in various ways. =item L This blog post describes how to handle optional modules with L. =item L This Japanese blog post describes why L now uses L over its competitors. =item L, L, L, etc This module was designed to be used anywhere you have C, which occurs in many large projects. =back =head1 AUTHOR Shawn M Moore =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Shawn M Moore. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Class-Load-0.20/lib/Class/Load/0000755000175000017500000000000012000631664015705 5ustar autarchautarchClass-Load-0.20/lib/Class/Load/PP.pm0000644000175000017500000000243712000631664016570 0ustar autarchautarchpackage Class::Load::PP; { $Class::Load::PP::VERSION = '0.20'; } use strict; use warnings; use Module::Runtime 'is_module_name'; use Package::Stash 0.14; use Scalar::Util 'blessed', 'reftype'; use Try::Tiny; sub is_class_loaded { my $class = shift; my $options = shift; my $loaded = _is_class_loaded($class); return $loaded if ! $loaded; return $loaded unless $options && $options->{-version}; return try { $class->VERSION($options->{-version}); 1; } catch { 0; }; } sub _is_class_loaded { my $class = shift; return 0 unless is_module_name($class); my $stash = Package::Stash->new($class); if ($stash->has_symbol('$VERSION')) { my $version = ${ $stash->get_symbol('$VERSION') }; if (defined $version) { return 1 if ! ref $version; # Sometimes $VERSION ends up as a reference to undef (weird) return 1 if ref $version && reftype $version eq 'SCALAR' && defined ${$version}; # a version object return 1 if blessed $version; } } if ($stash->has_symbol('@ISA')) { return 1 if @{ $stash->get_symbol('@ISA') }; } # check for any method return 1 if $stash->list_all_symbols('CODE'); # fail return 0; } 1; Class-Load-0.20/README0000644000175000017500000000046212000631664014075 0ustar autarchautarch This archive contains the distribution Class-Load, version 0.20: a working (require "Class::Name") and more This software is copyright (c) 2012 by Shawn M Moore. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Class-Load-0.20/LICENSE0000644000175000017500000004370312000631664014227 0ustar autarchautarchThis software is copyright (c) 2012 by Shawn M Moore. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012 by Shawn M Moore. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012 by Shawn M Moore. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Class-Load-0.20/META.yml0000644000175000017500000000150312000631664014463 0ustar autarchautarch--- abstract: "a working (require \"Class::Name\") and more" author: - 'Shawn M Moore ' build_requires: Test::Fatal: 0 Test::More: 0.88 Test::Requires: 0 constant: 0 version: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300016, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Class-Load requires: Carp: 0 Data::OptList: 0 Exporter: 0 Module::Implementation: 0.04 Module::Runtime: 0.012 Package::Stash: 0.14 Scalar::Util: 0 Try::Tiny: 0 base: 0 strict: 0 warnings: 0 resources: bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Load repository: git://github.com/autarch/class-load.git version: 0.20 Class-Load-0.20/Makefile.PL0000644000175000017500000000254112000631664015167 0ustar autarchautarch use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "a working (require \"Class::Name\") and more", "AUTHOR" => "Shawn M Moore ", "BUILD_REQUIRES" => { "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => 0, "constant" => 0, "version" => 0 }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Class-Load", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Class::Load", "PREREQ_PM" => { "Carp" => 0, "Data::OptList" => 0, "Exporter" => 0, "Module::Implementation" => "0.04", "Module::Runtime" => "0.012", "Package::Stash" => "0.14", "Scalar::Util" => 0, "Try::Tiny" => 0, "base" => 0, "strict" => 0, "warnings" => 0 }, "VERSION" => "0.20", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Class-Load-0.20/Changes0000644000175000017500000001016412000631664014510 0ustar autarchautarch0.20 2012-07-15 - Same as the most recently 0.19, but with a new version. 0.19 2012-07-15 - Uploaded by Dave Rolsky, not realizing 0.19 was already used - The load_class() subroutine now returns the class name on success. Requested by Caleb Cushing. RT #76931. - Exceptions and errors from Class::Load no longer contain references to line numbers in Class::Load or Module::Runtime. This applies to exceptions thrown by load_class, load_first_existing_class, and load_optional_class, as well as the error returned by try_load_class. - Exceptions are now croaked properly so they appear to come from the calling code, not from an internal subroutine. This makes the exceptions look more like the ones thrown by Perl's require. RT #68663. 0.19 2012-04-03 - Uploaded by doy (Jesse Luehrs) - No changes, reupload to fix indexing. 0.18 2012-02-18 - Require Package::Stash 0.14+. Fixes RT #75095. Reported by Zefram. 0.17 2012-02-12 - A bug in Class::Load caused test failures when Module::Runtime 0.012 was used with Perl 5.8.x. Reported by Zefram. RT #74897. ( Jesse Luehrs ) 0.16 2012-02-12 - Require Module::Runtime 0.012, which has a number of useful bug fixes. 0.15 2012-02-08 - Small test changes to accomodate latest version of Module::Implementation. There's no need to upgrade if you're already using 0.14 0.14 2012-02-06 - Use Module::Implementation to handle loading the XS or PP versions of the code. Using this module fixes a few bugs. - Under taint mode, setting an implementation in the CLASS_LOAD_IMPLEMENTATION env var caused a taint error. - An invalid value in the CLASS_LOAD_IMPLEMENTATION env var is now detected and reported immediately. No attempt is made to load an invalid implementation. 0.13 2011-12-22 - Fix some bugs with our use of Try::Tiny. This could cause warnings on some systems with Class::Load::XS wasn't installed. Fixes RT #72345. 0.12 2011-10-25 - Depend on Module::Runtime 0.011+. This fixes problems with Catalyst under Perl 5.8 and 5.10. 0.11 2011-10-04 - Don't accept package names that start with a digit. ( Jesse Luehrs ) - Rewrote some of the guts to use Module::Runtime, rather than reimplementing its functionality. ( Jesse Luehrs ) 0.10 2011-09-06 - Make sure the $@ localization doesn't hide errors - invalid module name errors were being suppressed on perls before 5.14. ( Jesse Luehrs ) 0.09 2011-09-05 - Fix is_class_loaded to ignore $ISA (but still look for @ISA) when trying to determine whether a class is loaded. ( Jesse Luehrs ) - Lots of internals cleanup. ( Jesse Luehrs ) 0.08 2011-08-15 - The previous version was missing a prereq declaration for Data::OptList. Reported by Daisuke Maki and Mark Hedges. RT #70285. 0.07 2011-08-15 - All this module's subroutines now accept optional parameters for a module so you can write something like - load_class( 'Foo', { -version => 42 } ) - There is now a Class::Load::XS distro available on CPAN which implements some of this module's code in XS for speed. This code was originally written by Goro Fuji and Florian Ragwitz for Class::MOP. You need to install this distro explicitly if you want the XS implementation. - Added a load_first_existing_class subroutine based, mostly borrowed from Class::MOP. - Fixed a bug where a package with a version object in its $VERSION would not be seen as loaded. Reported by Chris Prather. 0.06 2010-11-15 - BACK COMPAT CHANGE: Remove $Class::Load::ERROR in favor of a contextual return value. ( Jesse Luehrs ) - Add load_optional_class($class) that fails only if there is a problem with the attempted-to-load $class. ( Kent Fredric ) - Force internal require to try-again if we are SURE the class is not there. This produces reliable errors. ( Kent Fredric ) - Replace Test::Exception with Test::Fatal ( Kent Fredric ) 0.05 2009-09-02 - Cargo-cult Class::MOP's is_class_loaded so we work on 5.10 0.04 2008-11-09 - No changes 0.03 2008-11-09 - Dist fix 0.02 2008-11-09 - Declare dependency on Test::Exception 0.01 2008-08-13 - First version, released on an unsuspecting world. Class-Load-0.20/META.json0000644000175000017500000000313112000631664014632 0ustar autarchautarch{ "abstract" : "a working (require \"Class::Name\") and more", "author" : [ "Shawn M Moore " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300016, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Class-Load", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "runtime" : { "requires" : { "Carp" : "0", "Data::OptList" : "0", "Exporter" : "0", "Module::Implementation" : "0.04", "Module::Runtime" : "0.012", "Package::Stash" : "0.14", "Scalar::Util" : "0", "Try::Tiny" : "0", "base" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Test::Fatal" : "0", "Test::More" : "0.88", "Test::Requires" : "0", "constant" : "0", "version" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-class-load@rt.cpan.org", "web" : "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Load" }, "repository" : { "type" : "git", "url" : "git://github.com/autarch/class-load.git", "web" : "https://github.com/autarch/class-load" } }, "version" : "0.20" } Class-Load-0.20/INSTALL0000644000175000017500000000165412000631664014252 0ustar autarchautarch This is the Perl distribution Class-Load. Installing Class-Load is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm Class::Load If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S Class::Load ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan Class::Load ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install ## Documentation Class-Load documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc Class::Load Class-Load-0.20/dist.ini0000644000175000017500000000136612000631664014665 0ustar autarchautarchname = Class-Load author = Shawn M Moore license = Perl_5 copyright_holder = Shawn M Moore version = 0.20 [NextRelease] format = %-8v %{yyyy-MM-dd}d [@Basic] [InstallGuide] [MetaJSON] [MetaResources] bugtracker.web = http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Load bugtracker.mailto = bug-class-load@rt.cpan.org repository.url = git://github.com/autarch/class-load.git repository.web = https://github.com/autarch/class-load repository.type = git [SurgicalPodWeaver] [PkgVersion] [EOLTests] [NoTabsTests] [PodSyntaxTests] [Test::CPAN::Changes] [Test::Pod::LinkCheck] [Test::Pod::No404s] [CheckChangeLog] [AutoPrereqs] skip = Test::Spelling skip = Test::Without::Module [CheckPrereqsIndexed] [@Git]