Skip to content

Commit

Permalink
0.01 release
Browse files Browse the repository at this point in the history
  • Loading branch information
sshaw committed Dec 13, 2011
1 parent eca9b37 commit a13c7ec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 78 deletions.
41 changes: 15 additions & 26 deletions README.pod
Expand Up @@ -7,49 +7,38 @@ URI::fasp - URI handler for Aspera's FASP protocol
=head1 SYNOPSIS =head1 SYNOPSIS


$fasp = URI->new('fasp://example.com:97001?port=33001&bwcap=25000'); $fasp = URI->new('fasp://example.com:97001?port=33001&bwcap=25000');
$fasp->targetrate(10_000); print $fasp->port; # 97001
print $fasp->fasp_port; # 33001
print $fasp->query_param('bwcap') # 25000


print $fasp->port; # 97001
print $fasp->fasp_port; # 33001
print $fasp->bwcap; # 25000
# ... # ...
$ssh = $fasp->as_ssh; # URI::ssh
print $ssh->port; # 97001 $ssh = $fasp->as_ssh; # URI::ssh
print $ssh->port; # 97001


=head1 DESCRIPTION =head1 DESCRIPTION


Aspera uses seperate control and a data connections. The control connection is an SSH session. Aspera uses seperate control and a data connections. The control connection is a SSH session.
This class is a subclass of L<< C<URI::ssh> >> and uses the L<< C<URI::QueryParam> >> mixin.
This class is a subclass of L<< C<URI::ssh>|URI >> and uses the L<< C<URI::QueryParam> >> mixin.


=head1 METHODS =head1 METHODS


=head2 C<as_ssh> =head2 C<as_ssh>


L<< C<URI::ssh> >> representation of the instance's control connection Return a L<< C<URI::ssh>|URI >> representation of the instance's control connection


=head2 C<default_fasp_port> =head2 C<port>


The default FASP port is 33001 The port used by the control connection, defaults to C<22>


=head2 C<fasp_port> =head2 C<fasp_port>


Defaults to L<< C<default_fasp_port> >> The port used by the data connection, defaults to L<< C<default_fasp_port>|/default_fasp_port >>

=head2 C<bwcap>

Bandwidth cap


=head2 C<policy> =head2 C<default_fasp_port>

Transfer policy

=head2 C<httpport>

Fallback HTTP port

=head2 C<targetrate>


Target transfer rate The default port used by the data connection, C<33001>


=head1 SEE ALSO =head1 SEE ALSO


Expand Down
50 changes: 15 additions & 35 deletions lib/URI/fasp.pm
Expand Up @@ -8,20 +8,11 @@ use URI::QueryParam;


our $VERSION = '0.01'; our $VERSION = '0.01';


{
no strict 'refs';
for my $attr (qw|bwcap policy httpport targetrate|) {
*$attr = sub {
shift->query_param($attr, @_);
}
}
}

sub _init { shift->SUPER::_init(@_); } sub _init { shift->SUPER::_init(@_); }
sub default_fasp_port { 33001 } sub default_fasp_port { 33001 }


# Aspera uses "port". To avoid conflicting with the URI method of the same name we call # Aspera uses "port" to denote the FASP port. To avoid conflicting with the URI method of the
# this method "fasp_port". Both names are supported as query params. # same name we call this method "fasp_port".
sub fasp_port sub fasp_port
{ {
my $self = shift; my $self = shift;
Expand Down Expand Up @@ -54,49 +45,38 @@ URI::fasp - URI handler for Aspera's FASP protocol
=head1 SYNOPSIS =head1 SYNOPSIS
$fasp = URI->new('fasp://example.com:97001?port=33001&bwcap=25000'); $fasp = URI->new('fasp://example.com:97001?port=33001&bwcap=25000');
$fasp->targetrate(10_000); print $fasp->port; # 97001
print $fasp->fasp_port; # 33001
print $fasp->query_param('bwcap') # 25000
print $fasp->port; # 97001
print $fasp->fasp_port; # 33001
print $fasp->bwcap; # 25000
# ... # ...
$ssh = $fasp->as_ssh; # URI::ssh
print $ssh->port; # 97001 $ssh = $fasp->as_ssh; # URI::ssh
print $ssh->port; # 97001
=head1 DESCRIPTION =head1 DESCRIPTION
Aspera uses seperate control and a data connections. The control connection is a SSH session. Aspera uses seperate control and a data connections. The control connection is a SSH session.
This class is a subclass of L<< C<URI::ssh>|URI >> and uses the L<< C<URI::QueryParam> >> mixin. This class is a subclass of L<< C<URI::ssh>|URI >> and uses the L<< C<URI::QueryParam> >> mixin.
=head1 METHODS =head1 METHODS
=head2 C<as_ssh> =head2 C<as_ssh>
L<< C<URI::ssh>|URI >> representation of the instance's control connection Return a L<< C<URI::ssh>|URI >> representation of the instance's control connection
=head2 C<default_fasp_port> =head2 C<port>
The default FASP port is 33001 The port used by the control connection, defaults to C<22>
=head2 C<fasp_port> =head2 C<fasp_port>
Defaults to L<< C<default_fasp_port> >> The port used by the data connection, defaults to L<< C<default_fasp_port>|/default_fasp_port >>
=head2 C<bwcap>
Bandwidth cap =head2 C<default_fasp_port>
=head2 C<policy>
Transfer policy
=head2 C<httpport>
Fallback HTTP port
=head2 C<targetrate>
Target transfer rate The default port used by the data connection, C<33001>
=head1 SEE ALSO =head1 SEE ALSO
Expand Down
19 changes: 2 additions & 17 deletions t/fasp.t
Expand Up @@ -2,7 +2,7 @@ use strict;
use warnings; use warnings;


use URI; use URI;
use Test::More tests => 19; use Test::More tests => 11;


my $uri = URI->new('fasp://example.com'); my $uri = URI->new('fasp://example.com');
isa_ok($uri, 'URI::fasp'); isa_ok($uri, 'URI::fasp');
Expand All @@ -11,30 +11,15 @@ is($uri->default_fasp_port, 33001);
is($uri->fasp_port, 33001); is($uri->fasp_port, 33001);
is("$uri", 'fasp://example.com'); is("$uri", 'fasp://example.com');


# Like URI we only show the port if it's explicitly set # Like other URI subclasses the port should only be shown if it's explicitly set
$uri->fasp_port(33001); $uri->fasp_port(33001);
is("$uri", 'fasp://example.com?port=33001'); is("$uri", 'fasp://example.com?port=33001');


$uri = URI->new('fasp://example.com:33001?port=5000&bwcap=1000&policy=fair&httpport=8080&targetrate=50000'); $uri = URI->new('fasp://example.com:33001?port=5000&bwcap=1000&policy=fair&httpport=8080&targetrate=50000');
is($uri->fasp_port, 5000); is($uri->fasp_port, 5000);
is($uri->port, 33001);
is($uri->bwcap, 1000);
is($uri->policy, 'fair');
is($uri->httpport, 8080);
is($uri->targetrate, 50000);

$uri->fasp_port(33001); $uri->fasp_port(33001);
is($uri->fasp_port, 33001); is($uri->fasp_port, 33001);


$uri->bwcap(25000);
is($uri->bwcap, 25000);

$uri->policy('unlimited');
is($uri->policy, 'unlimited');

$uri->targetrate(100000);
is($uri->targetrate, 100000);

my $ssh = $uri->as_ssh; my $ssh = $uri->as_ssh;
isa_ok($ssh, 'URI::ssh'); isa_ok($ssh, 'URI::ssh');
is($ssh->port, 33001); is($ssh->port, 33001);
Expand Down

0 comments on commit a13c7ec

Please sign in to comment.