Skip to content

Commit

Permalink
Allow domain and version of the API url to be settable via
Browse files Browse the repository at this point in the history
MetaCPAN::Client.

The docs say you can set these in the request object directly, but they
also say MetaCPAN::Client->request is for internal use.  It would be
easier if these attributes were settable when creating a new client,
just as the UA is.
  • Loading branch information
oalders committed Oct 15, 2014
1 parent 0831027 commit a28c5ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/MetaCPAN/Client.pm
Expand Up @@ -31,6 +31,8 @@ sub BUILDARGS {

$args{'request'} ||= MetaCPAN::Client::Request->new(
( ua => $args{'ua'} ) x !! $args{'ua'},
$args{domain} ? ( domain => $args{domain} ) : (),
$args{version} ? ( version => $args{version} ) : (),
);

return \%args;
Expand Down
6 changes: 5 additions & 1 deletion t/request.t
Expand Up @@ -3,7 +3,8 @@
use strict;
use warnings;

use Test::More tests => 7;
use Test::More tests => 9;
use MetaCPAN::Client;
use MetaCPAN::Client::Request;

my $req = MetaCPAN::Client::Request->new( domain => 'mydomain', version => 'z' );
Expand All @@ -27,3 +28,6 @@ is_deeply(
'Correct UA args',
);

my $client = MetaCPAN::Client->new( domain => 'foo', version => 'bar' );
is ( $client->request->domain, 'foo', 'domain set in request' );
is ( $client->request->version, 'bar', 'version set in request' );

0 comments on commit a28c5ec

Please sign in to comment.