Browse files

removed some redundancy

  • Loading branch information...
1 parent 8cb960c commit 7014447a390579f00748b1510a211b6a504ec82d sshaw committed Dec 3, 2011
Showing with 20 additions and 20 deletions.
  1. +13 −19 lib/URI/fasp.pm
  2. +7 −1 t/fasp.t
View
32 lib/URI/fasp.pm
@@ -10,25 +10,32 @@ use URI::QueryParam;
our $VERSION = '0.01';
+{
+ no strict 'refs';
+ for my $attr (qw|bwcap policy httpport targetrate|) {
+ *$attr = sub {
+ shift->query_param($attr, @_);
+ }
+ }
+}
+
sub _init
{
my $class = shift;
my $self = $class->SUPER::_init(@_);
$self->faspport($self->default_faspport) unless defined $self->faspport;
- # Other defaults
+ # Other defaults...
$self;
}
-sub bwcap { shift->_query_param('bwcap', @_); }
-sub policy { shift->_query_param('policy', @_); }
-sub httpport { shift->_query_param('httpport', @_); }
-sub targetrate { shift->_query_param('targetrate', @_); }
sub default_faspport { 33001 }
sub faspport
{
my $self = shift;
- return $self->_query_param('port', @_) if @_;
+ return $self->query_param('port', @_) if @_;
+
+ # No need to entertain a list
my $port = $self->query_param('port') ||
$self->query_param('faspport');
$port;
@@ -43,19 +50,6 @@ sub as_ssh
$ssh;
}
-sub _query_param
-{
- my ($self, $param, $value) = @_;
-
- # Do we need to accept multiple args here?
- if($value) {
- $self->query_param($param, $value);
- return;
- }
-
- $self->query_param($param);
-}
-
1;
=pod
View
8 t/fasp.t
@@ -2,7 +2,7 @@ use strict;
use warnings;
use URI;
-use Test::More tests => 15;
+use Test::More tests => 17;
my $uri = URI->new('fasp://example.com');
isa_ok($uri, 'URI::fasp');
@@ -32,3 +32,9 @@ is($uri->targetrate, 100000);
my $ssh = $uri->as_ssh;
isa_ok($ssh, 'URI::ssh');
is($ssh->port, 33001);
+is($ssh->query, undef);
+
+# Aspera uses "port", we use that and "faspport"
+$uri = URI->new('fasp://example.com:33001?faspport=5000');
+is($uri->faspport, 5000);
+

0 comments on commit 7014447

Please sign in to comment.