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

? sunnavy sunnavy at bestpractical.com
Thu Apr 29 20:25:47 EDT 2010


The branch, master has been updated
       via  1d6bdc01d1a747db3d88afd0a6df303c7147ae84 (commit)
       via  9dd99897096a50e64ead9ca18efcce435a1a213d (commit)
       via  ad49e3650a34572a596923a1e14d0c56d0f0ef34 (commit)
      from  08a90a84371adc9f5241200803b17c6e69e5e706 (commit)

Summary of changes:
 bin/plient             |   20 +++++++++++++++++---
 lib/Plient.pm          |    8 +++++---
 lib/Plient/Protocol.pm |    5 +++--
 t/01.plient.t          |    2 +-
 4 files changed, 26 insertions(+), 9 deletions(-)

- Log -----------------------------------------------------------------
commit ad49e3650a34572a596923a1e14d0c56d0f0ef34
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 30 07:00:22 2010 +0800

    rename available to plient_support

diff --git a/lib/Plient.pm b/lib/Plient.pm
index b81707f..bb33ebe 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 @EXPORT_OK = 'plient_support';
 our $bundle_mode = $ENV{PLIENT_BUNDLE_MODE};
 
 sub plient {
@@ -75,12 +76,12 @@ sub _dispatch_protocol {
 }
 
 
-sub available {
+sub plient_support {
     shift if $_[0] && $_[0] eq __PACKAGE__;
     my ( $protocol, $method, $args ) = @_;
     return unless $protocol;
     $method ||= 'get';
-    my $class = _dispatch_protocol(lc $protocol);
+    my $class = _dispatch_protocol( lc $protocol );
     return unless $class;
     return $class->support_method( $method, $args );
 }
diff --git a/t/01.plient.t b/t/01.plient.t
index 0acad47..190645b 100644
--- a/t/01.plient.t
+++ b/t/01.plient.t
@@ -5,7 +5,7 @@ use Test::More tests => 5;
 
 use_ok( 'Plient' );
 
-ok( Plient->available('File','GET'), 'supports File GET' );
+ok( Plient->plient_support('File','GET'), 'supports File GET' );
 # ok( Plient->available('HTTP','GET'), 'supports HTTP GET' );
 
 

commit 9dd99897096a50e64ead9ca18efcce435a1a213d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 30 07:04:54 2010 +0800

    don't warn if we are just checking

diff --git a/lib/Plient.pm b/lib/Plient.pm
index bb33ebe..22852ec 100644
--- a/lib/Plient.pm
+++ b/lib/Plient.pm
@@ -81,9 +81,10 @@ sub plient_support {
     my ( $protocol, $method, $args ) = @_;
     return unless $protocol;
     $method ||= 'get';
+    $args   ||= {};
     my $class = _dispatch_protocol( lc $protocol );
     return unless $class;
-    return $class->support_method( $method, $args );
+    return $class->support_method( $method, { %$args, check_only => 1 } );
 }
 
 sub dispatch {
diff --git a/lib/Plient/Protocol.pm b/lib/Plient/Protocol.pm
index 1172650..2143c8d 100644
--- a/lib/Plient/Protocol.pm
+++ b/lib/Plient/Protocol.pm
@@ -11,8 +11,9 @@ sub support_method {
     # trans $args here to let handlers to decide to pass or not
     my ( $class, $method_name, $args ) = @_;
     $method_name = lc $method_name;
+    $args ||= {};
 
-    if ( !grep { $method_name eq $_ } $class->methods ) {
+    if ( ! $args->{check_only} && !grep { $method_name eq $_ } $class->methods ) {
         warn "$method_name for $class is not officially supported yet";
     }
 
@@ -26,7 +27,7 @@ sub support_method {
             return $method;
         }
     }
-    warn "$handler_method_name is not supported yet";
+    warn "$handler_method_name is not supported yet" unless $args->{check_only};
     return;
 }
 

commit 1d6bdc01d1a747db3d88afd0a6df303c7147ae84
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 30 07:05:27 2010 +0800

    add --support arg

diff --git a/bin/plient b/bin/plient
index 6bbca04..4782448 100755
--- a/bin/plient
+++ b/bin/plient
@@ -3,20 +3,34 @@ use strict;
 use warnings;
 use Getopt::Long;
 require Plient unless $ENV{PLIENT_BUNDLE_MODE};
-Plient->import;
+Plient->import( 'plient', 'plient_support' );
 
 my %args;
 
-GetOptions( \%args, 'help|h' ) or die 'unknown option';
+GetOptions( \%args, 'help|h', 'support|s=s' ) or die 'unknown option';
 
 my $USAGE =<<EOF;
 USAGE: plient [METHOD] URL [ ... ]
 EXAMPLES:
     plient http://cpan.org/                         # fetch http://cpan.org
     plient get http://cpan.org/                     # ditto
+    plient --support http_get                       # check is support HTTP GET
+    plient -s http_get                              # ditto
 EOF
 
-if ( $args{help} || !$ARGV[0] ) {
+if ( $args{help} ) {
+    print $USAGE;
+    exit;
+}
+
+if ( $args{support} ) {
+    my ( $protocol, $method ) = split /_/, $args{support}, 2;
+    print plient_support( $protocol, $method ) ? 'yes' : 'no';
+    print "\n";
+    exit;
+}
+
+if ( !$ARGV[0] ) {
     print $USAGE;
     exit;
 }

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



More information about the Bps-public-commit mailing list