[Socialtext-commits] SF.net SVN: socialtext: [1004] branches/rug
Brought to you by:
socialtextrocks
|
From: <pet...@us...> - 2007-01-30 23:07:41
|
Revision: 1004
http://svn.sourceforge.net/socialtext/?rev=1004&view=rev
Author: petdance
Date: 2007-01-30 15:07:33 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
Hoisted all the webapi lookups out of Socialtext::Rug into Socialtext::Build
Modified Paths:
--------------
branches/rug/etc/init.d/st-apache
branches/rug/lib/Socialtext/Build.pm
branches/rug/lib/Socialtext/Handler/Cleanup.pm
branches/rug/lib/Socialtext/Rug/Constants.pm
branches/rug/lib/Socialtext/Rug/Cookie.pm
branches/rug/lib/Socialtext/Rug.pm
Modified: branches/rug/etc/init.d/st-apache
===================================================================
--- branches/rug/etc/init.d/st-apache 2007-01-30 22:36:19 UTC (rev 1003)
+++ branches/rug/etc/init.d/st-apache 2007-01-30 23:07:33 UTC (rev 1004)
@@ -15,8 +15,7 @@
);
# XXX Hoist into a module
-my $webapi = get_build_setting( 'webapi' );
-my $short_name = $webapi eq 'mod_perl1' ? 'apache-perl' : 'apache2';
+my $short_name = Socialtext::Build::is_mod_perl1() ? 'apache-perl' : 'apache2';
Readonly my $PREFIX => get_build_setting( 'prefix' );
Readonly my $BINDIR => get_build_setting( 'bindir' );
Modified: branches/rug/lib/Socialtext/Build.pm
===================================================================
--- branches/rug/lib/Socialtext/Build.pm 2007-01-30 22:36:19 UTC (rev 1003)
+++ branches/rug/lib/Socialtext/Build.pm 2007-01-30 23:07:33 UTC (rev 1004)
@@ -68,7 +68,25 @@
return ( scalar getpwnam( $user ), scalar getgrnam( $group ) );
}
+=head2 webapi()
+Returns the web API we're using, either mod_perl1 or mod_perl2.
+
+=head2 is_mod_perl1()
+
+Returns true if the user has configured mod_perl1.
+
+=head2 is_mod_perl2()
+
+Returns true if the user has configured mod_perl2.
+
+=cut
+
+sub webapi { return get_build_setting( 'webapi' ) }
+sub is_mod_perl1 { return webapi() eq 'mod_perl1' }
+sub is_mod_perl2 { return webapi() eq 'mod_perl2' }
+
+
sub _load_defaults {
my $defaults_pl = _defaults_pl();
if ($defaults_pl) {
Modified: branches/rug/lib/Socialtext/Handler/Cleanup.pm
===================================================================
--- branches/rug/lib/Socialtext/Handler/Cleanup.pm 2007-01-30 22:36:19 UTC (rev 1003)
+++ branches/rug/lib/Socialtext/Handler/Cleanup.pm 2007-01-30 23:07:33 UTC (rev 1004)
@@ -32,11 +32,9 @@
} # handler
BEGIN {
- my $webapi = get_build_setting( 'webapi' );
-
# We want A::SL to be optional since it doesn't work on all
# platforms, and isn't really criticial.
- if ( $webapi eq 'mod_perl1' ) {
+ if ( Socialtext::Build::is_mod_perl1() ) {
if ( eval { require Apache::SizeLimit; 1 } ) {
# Why is this necessary?
#
@@ -74,7 +72,7 @@
die $@ unless $@ =~ m{\QCan't locate Apache/SizeLimit.pm};
}
} # mod_perl1
- elsif ( $webapi eq 'mod_perl2' ) {
+ elsif ( Socialtext::Build::is_mod_perl2() ) {
require Apache2::SizeLimit;
$worker = sub {
no warnings 'once';
@@ -86,7 +84,7 @@
}
} # mod_perl2
else {
- die qq{Unknown webapi "$webapi"};
+ die 'Unknown web API';
}
} # BEGIN
Modified: branches/rug/lib/Socialtext/Rug/Constants.pm
===================================================================
--- branches/rug/lib/Socialtext/Rug/Constants.pm 2007-01-30 22:36:19 UTC (rev 1003)
+++ branches/rug/lib/Socialtext/Rug/Constants.pm 2007-01-30 23:07:33 UTC (rev 1004)
@@ -10,21 +10,20 @@
use strict;
use warnings;
-use Socialtext::Rug;
+use Socialtext::Build ();
sub import {
shift;
- my $api = Socialtext::Rug->webapi;
my $caller = (caller)[0];
- if ( $api eq 'mod_perl1' ) {
+ if ( Socialtext::Build::is_mod_perl1() ) {
require Apache::Constants;
eval "package $caller; use Apache::Constants qw( @_ )";
die $@ if $@;
}
- elsif ( $api eq 'mod_perl2' ) {
+ elsif ( Socialtext::Build::is_mod_perl2() ) {
require Apache2::Const;
my @imports = @_;
@@ -36,7 +35,7 @@
die $@ if $@;
}
else {
- die "Unknown API $api";
+ die "Unknown API";
}
}
Modified: branches/rug/lib/Socialtext/Rug/Cookie.pm
===================================================================
--- branches/rug/lib/Socialtext/Rug/Cookie.pm 2007-01-30 22:36:19 UTC (rev 1003)
+++ branches/rug/lib/Socialtext/Rug/Cookie.pm 2007-01-30 23:07:33 UTC (rev 1004)
@@ -18,17 +18,16 @@
our $CookieClass;
BEGIN: {
- my $api = Socialtext::Rug->webapi;
- if ( $api eq 'mod_perl1' ) {
+ if ( Socialtext::Build::is_mod_perl1() ) {
require Apache::Cookie;
$CookieClass = 'Apache::Cookie';
}
- elsif ( $api eq 'mod_perl2' ) {
+ elsif ( Socialtext::Build::is_mod_perl2() ) {
require Apache2::Cookie;
$CookieClass = 'Apache2::Cookie';
}
else {
- die "Unknown web API $api";
+ die "Unknown web API";
}
}
@@ -51,7 +50,7 @@
sub fetch {
shift;
- if ( $api eq 'mod_perl1' ) {
+ if ( Socialtext::Build::is_mod_perl1() ) {
shift; # Remove the unused $r passed in
}
Modified: branches/rug/lib/Socialtext/Rug.pm
===================================================================
--- branches/rug/lib/Socialtext/Rug.pm 2007-01-30 22:36:19 UTC (rev 1003)
+++ branches/rug/lib/Socialtext/Rug.pm 2007-01-30 23:07:33 UTC (rev 1004)
@@ -13,21 +13,8 @@
use strict;
use warnings;
-use Socialtext::Build qw( get_build_setting );
use Socialtext::Validate qw( validate_pos APACHE_TYPE );
-=head1 FUNCTIONS
-
-=head2 webapi()
-
-Function that returns the API that we're using, either "mod_perl1" or "mod_perl2".
-
-=cut
-
-sub webapi {
- return get_build_setting( 'webapi' );
-}
-
=head1 METHODS
=head2 instance( [$r] )
@@ -54,10 +41,10 @@
sub _determine_subclass {
my $class = shift;
- if ( $class->webapi eq 'mod_perl1' ) {
+ if ( Socialtext::Build::is_mod_perl1() ) {
return 'Socialtext::Rug::MP1';
}
- elsif ( $class->webapi eq 'mod_perl2' ) {
+ elsif ( Socialtext::Build::is_mod_perl2() ) {
return 'Socialtext::Rug::MP2';
}
else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|