[Bps-public-commit] plient branch, master, updated. b93ab90f170f927ea090a31781832e2f3f8c8fed

? sunnavy sunnavy at bestpractical.com
Tue Apr 27 15:18:00 EDT 2010


The branch, master has been updated
       via  b93ab90f170f927ea090a31781832e2f3f8c8fed (commit)
      from  07f04bf24ac53422ac4c91426e91dff1c7a9baff (commit)

Summary of changes:
 bin/plient                     |    3 ++-
 lib/Plient.pm                  |    8 +++++---
 lib/Plient/Handler/HTTPLite.pm |    5 ++++-
 lib/Plient/Handler/LWP.pm      |    5 ++++-
 lib/Plient/Handler/curl.pm     |    8 ++++++--
 lib/Plient/Handler/wget.pm     |   11 +++++++++--
 lib/Plient/Protocol/File.pm    |    4 ++--
 lib/Plient/Protocol/HTTP.pm    |    4 ++--
 lib/Plient/Protocol/HTTPS.pm   |    4 ++--
 9 files changed, 36 insertions(+), 16 deletions(-)

- Log -----------------------------------------------------------------
commit b93ab90f170f927ea090a31781832e2f3f8c8fed
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Apr 27 10:37:15 2010 +0800

    add bundle_mode

diff --git a/bin/plient b/bin/plient
index f0a0b62..6bbca04 100755
--- a/bin/plient
+++ b/bin/plient
@@ -1,8 +1,9 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Plient;
 use Getopt::Long;
+require Plient unless $ENV{PLIENT_BUNDLE_MODE};
+Plient->import;
 
 my %args;
 
diff --git a/lib/Plient.pm b/lib/Plient.pm
index 9a17042..b81707f 100644
--- a/lib/Plient.pm
+++ b/lib/Plient.pm
@@ -7,6 +7,7 @@ our $VERSION = '0.01';
 use File::Spec::Functions;
 use base 'Exporter';
 our @EXPORT = 'plient';
+our $bundle_mode = $ENV{PLIENT_BUNDLE_MODE};
 
 sub plient {
     my ( $method, $uri, $args ) = @_;
@@ -56,15 +57,15 @@ sub _dispatch_protocol {
     my $protocol = shift;
     return unless $protocol;
     if ( $protocol eq 'file' ) {
-        require Plient::Protocol::File;
+        require Plient::Protocol::File unless $bundle_mode;
         return 'Plient::Protocol::File';
     }
     elsif ( $protocol eq 'http' ) {
-        require Plient::Protocol::HTTP;
+        require Plient::Protocol::HTTP unless $bundle_mode;
         return 'Plient::Protocol::HTTP';
     }
     elsif ( $protocol eq 'https' ) {
-        require Plient::Protocol::HTTPS;
+        require Plient::Protocol::HTTPS unless $bundle_mode;
         return 'Plient::Protocol::HTTPS';
     }
     else {
@@ -154,6 +155,7 @@ sub handlers {
 
 sub find_handlers {
     $found_handlers = 1;
+    return if $bundle_mode;
     my @hd;
     for my $inc (@INC) {
         my $handler_dir = catdir( $inc, 'Plient', 'Handler' );
diff --git a/lib/Plient/Handler/HTTPLite.pm b/lib/Plient/Handler/HTTPLite.pm
index 9d2a8cd..3fd7be0 100644
--- a/lib/Plient/Handler/HTTPLite.pm
+++ b/lib/Plient/Handler/HTTPLite.pm
@@ -2,7 +2,8 @@ package Plient::Handler::HTTPLite;
 use strict;
 use warnings;
 
-use base 'Plient::Handler';
+require Plient::Handler unless $Plient::bundle_mode;
+our @ISA = 'Plient::Handler';
 my ( $HTTPLite, %all_protocol, %protocol, %method );
 
 %all_protocol = ( http => undef );
@@ -50,6 +51,8 @@ sub init {
     return 1;
 }
 
+__PACKAGE__->_add_to_plient if $Plient::bundle_mode;
+
 1;
 
 __END__
diff --git a/lib/Plient/Handler/LWP.pm b/lib/Plient/Handler/LWP.pm
index d0bf7d0..8db3fc8 100644
--- a/lib/Plient/Handler/LWP.pm
+++ b/lib/Plient/Handler/LWP.pm
@@ -2,7 +2,8 @@ package Plient::Handler::LWP;
 use strict;
 use warnings;
 
-use base 'Plient::Handler';
+require Plient::Handler unless $Plient::bundle_mode;
+our @ISA = 'Plient::Handler';
 my ( $LWP, %all_protocol, %protocol, %method );
 
 %all_protocol = map { $_ => undef }
@@ -83,6 +84,8 @@ sub init {
     return 1;
 }
 
+__PACKAGE__->_add_to_plient if $Plient::bundle_mode;
+
 1;
 
 __END__
diff --git a/lib/Plient/Handler/curl.pm b/lib/Plient/Handler/curl.pm
index 858d603..a0540f4 100644
--- a/lib/Plient/Handler/curl.pm
+++ b/lib/Plient/Handler/curl.pm
@@ -2,8 +2,11 @@ package Plient::Handler::curl;
 use strict;
 use warnings;
 
-use base 'Plient::Handler';
-use Plient::Util 'which';
+require Plient::Handler unless $Plient::bundle_mode;
+our @ISA = 'Plient::Handler';
+
+require Plient::Util unless $Plient::bundle_mode;
+Plient::Util->import;
 
 my ( $curl, $curl_config, %all_protocol, %protocol, %method );
 
@@ -98,6 +101,7 @@ sub init {
     return 1;
 }
 
+__PACKAGE__->_add_to_plient if $Plient::bundle_mode;
 1;
 
 __END__
diff --git a/lib/Plient/Handler/wget.pm b/lib/Plient/Handler/wget.pm
index f05632a..15f3e40 100644
--- a/lib/Plient/Handler/wget.pm
+++ b/lib/Plient/Handler/wget.pm
@@ -2,8 +2,11 @@ package Plient::Handler::wget;
 use strict;
 use warnings;
 
-use base 'Plient::Handler';
-use Plient::Util 'which';
+require Plient::Handler unless $Plient::bundle_mode;
+our @ISA = 'Plient::Handler';
+
+require Plient::Util unless $Plient::bundle_mode;
+Plient::Util->import;
 
 my ( $wget, %protocol, %all_protocol, %method );
 
@@ -118,8 +121,12 @@ sub init {
     return 1;
 }
 
+__PACKAGE__->_add_to_plient if $Plient::bundle_mode;
+
 1;
 
+__END__
+
 =head1 NAME
 
 Plient::Handler::wget - 
diff --git a/lib/Plient/Protocol/File.pm b/lib/Plient/Protocol/File.pm
index 0eb82c2..b9623f0 100644
--- a/lib/Plient/Protocol/File.pm
+++ b/lib/Plient/Protocol/File.pm
@@ -2,8 +2,8 @@ package Plient::Protocol::File;
 
 use warnings;
 use strict;
-use Carp;
-use base 'Plient::Protocol';
+require Plient::Protocol unless $Plient::bundle_mode;
+our @ISA = 'Plient::Protocol';
 
 sub prefix { 'file' }
 sub methods { qw/get/ }
diff --git a/lib/Plient/Protocol/HTTP.pm b/lib/Plient/Protocol/HTTP.pm
index 25b6f89..7a6a37c 100644
--- a/lib/Plient/Protocol/HTTP.pm
+++ b/lib/Plient/Protocol/HTTP.pm
@@ -2,8 +2,8 @@ package Plient::Protocol::HTTP;
 
 use warnings;
 use strict;
-use Carp;
-use base 'Plient::Protocol';
+require Plient::Protocol unless $Plient::bundle_mode;
+our @ISA = 'Plient::Protocol';
 
 sub prefix { 'http' }
 sub methods { qw/get post head/ }
diff --git a/lib/Plient/Protocol/HTTPS.pm b/lib/Plient/Protocol/HTTPS.pm
index e5951dc..9ae7e64 100644
--- a/lib/Plient/Protocol/HTTPS.pm
+++ b/lib/Plient/Protocol/HTTPS.pm
@@ -2,8 +2,8 @@ package Plient::Protocol::HTTPS;
 
 use warnings;
 use strict;
-use Carp;
-use base 'Plient::Protocol::HTTP';
+require Plient::Protocol::HTTP unless $Plient::bundle_mode;
+our @ISA = 'Plient::Protocol::HTTP';
 
 sub prefix { 'https' }
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list