[Bast-commits] r8199 - in
branches/DBIx-Class-Schema-Loader/current: .
lib/DBIx/Class/Schema/Loader t t/lib t/lib/DBICTest
t/lib/DBICTest/Schema t/lib/DBICTest/Schema/13
t/lib/DBICTest/Schema/14
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Thu Dec 31 02:19:38 GMT 2009
Author: caelum
Date: 2009-12-31 02:19:37 +0000 (Thu, 31 Dec 2009)
New Revision: 8199
Added:
branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/
branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/
branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/13/
branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/13/Foo.pm
branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/14/
branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/14/Foo.pm
Modified:
branches/DBIx-Class-Schema-Loader/current/
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm
branches/DBIx-Class-Schema-Loader/current/t/20invocations.t
Log:
r22323 at hlagh (orig r8196): caelum | 2009-12-30 17:04:48 -0500
new branch to add an option to turn off loading external custom content
r22324 at hlagh (orig r8197): jhannah | 2009-12-30 21:00:47 -0500
Added skip_load_external()
r22325 at hlagh (orig r8198): caelum | 2009-12-30 21:19:13 -0500
minor test cleanup
Property changes on: branches/DBIx-Class-Schema-Loader/current
___________________________________________________________________
Name: svk:merge
- 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/back-compat:8172
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/deprecate_CDA:8193
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/mssql_tweaks:7407
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726
+ 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/back-compat:8172
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/deprecate_CDA:8193
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/mssql_tweaks:7407
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/skip_load_external:8198
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm 2009-12-31 02:19:13 UTC (rev 8198)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm 2009-12-31 02:19:37 UTC (rev 8199)
@@ -30,6 +30,7 @@
components
resultset_components
skip_relationships
+ skip_load_external
moniker_map
inflect_singular
inflect_plural
@@ -83,6 +84,11 @@
Skip setting up relationships. The default is to attempt the loading
of relationships.
+=head2 skip_load_external
+
+Skip loading of other classes in @INC. The default is to merge all other classes
+with the same name found in @INC into the schema file we are creating.
+
=head2 naming
Static schemas (ones dumped to disk) will, by default, use the new-style 0.05XXX
@@ -479,6 +485,8 @@
sub _load_external {
my ($self, $class) = @_;
+ return if $self->{skip_load_external};
+
# so that we don't load our own classes, under any circumstances
local *INC = [ grep $_ ne $self->dump_directory, @INC ];
Modified: branches/DBIx-Class-Schema-Loader/current/t/20invocations.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/20invocations.t 2009-12-31 02:19:13 UTC (rev 8198)
+++ branches/DBIx-Class-Schema-Loader/current/t/20invocations.t 2009-12-31 02:19:37 UTC (rev 8199)
@@ -103,14 +103,43 @@
[ $make_dbictest_db::dsn ],
);
DBICTest::Schema::12->clone;
- }
+ },
+ 'skip_load_external_1' => sub {
+ # By default we should pull in t/lib/DBICTest/Schema/13/Foo.pm $skip_me since t/lib is in @INC
+ use DBIx::Class::Schema::Loader;
+ DBIx::Class::Schema::Loader::make_schema_at(
+ 'DBICTest::Schema::13',
+ { really_erase_my_files => 1, naming => 'current' },
+ [ $make_dbictest_db::dsn ],
+ );
+ DBICTest::Schema::13->clone;
+ },
+ 'skip_load_external_2' => sub {
+ # When we explicitly skip_load_external t/lib/DBICTest/Schema/14/Foo.pm should be ignored
+ use DBIx::Class::Schema::Loader;
+ DBIx::Class::Schema::Loader::make_schema_at(
+ 'DBICTest::Schema::14',
+ { really_erase_my_files => 1, naming => 'current', skip_load_external => 1 },
+ [ $make_dbictest_db::dsn ],
+ );
+ DBICTest::Schema::14->clone;
+ },
);
# 4 tests per k/v pair
-plan tests => 2 * @invocations;
+plan tests => 2 * @invocations + 2; # + 2 more manual ones below.
while(@invocations >= 2) {
my $style = shift @invocations;
my $subref = shift @invocations;
test_schema($style, &$subref);
}
+
+{
+ no warnings 'once';
+
+ is($DBICTest::Schema::13::Foo::skip_me, "bad mojo",
+ "external content loaded");
+ is($DBICTest::Schema::14::Foo::skip_me, undef,
+ "external content not loaded with skip_load_external => 1");
+}
Added: branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/13/Foo.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/13/Foo.pm (rev 0)
+++ branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/13/Foo.pm 2009-12-31 02:19:37 UTC (rev 8199)
@@ -0,0 +1,3 @@
+package DBICTest::Schema::13::Foo;
+our $skip_me = "bad mojo";
+1;
Added: branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/14/Foo.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/14/Foo.pm (rev 0)
+++ branches/DBIx-Class-Schema-Loader/current/t/lib/DBICTest/Schema/14/Foo.pm 2009-12-31 02:19:37 UTC (rev 8199)
@@ -0,0 +1,3 @@
+package DBICTest::Schema::14::Foo;
+our $skip_me = "bad mojo";
+1;
More information about the Bast-commits
mailing list