Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
Merge branch 'bricas'
Browse files Browse the repository at this point in the history
* bricas:
  use eq and ne instead of a regex
  pod fix
  confess when we are unable to fetch a spec via LWP
  remove unused var; simplify conditions
  fix warnings in test
  • Loading branch information
fcuny committed Jan 2, 2012
2 parents d41d8b6 + 84acaa5 commit f61a039
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions lib/Net/HTTP/Spore.pm
Expand Up @@ -88,13 +88,8 @@ sub _attach_spec_to_class {
};

try {
my $base_url;
if ( $spec->{base_url} && !$opts->{base_url} ) {
$opts->{base_url} = $spec->{base_url};
}
elsif ( !$opts->{base_url} ) {
die "base_url is missing!";
}
$opts->{base_url} ||= $spec->{base_url};
die "base_url is missing!" if !$opts->{base_url};

if ( $spec->{formats} ) {
$opts->{formats} = $spec->{formats};
Expand Down Expand Up @@ -126,6 +121,10 @@ sub _read_spec {
my $req = HTTP::Request->new( GET => $spec_file );
my $ua = LWP::UserAgent->new();
my $res = $ua->request($req);
unless( $res->is_success ) {
my $status = $res->status_line;
Carp::confess("Unabled to fetch $spec_file ($status)");
}
$content = $res->content;
}
else {
Expand Down Expand Up @@ -215,7 +214,7 @@ L<Net::HTTP::Spore> provides a way to trace what's going on when doing a request
=head3 Enabling Trace
You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E-<GT> 1> when calling B<new_from_spec>.
You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E<gt> 1> when calling B<new_from_spec>.
=head3 Trace Output
Expand Down
6 changes: 3 additions & 3 deletions t/spore/02_enable.t
Expand Up @@ -26,15 +26,15 @@ is scalar @{$client->middlewares}, 0, 'no middleware';

dies_ok {
$client->enable();
}, 'middleware name is required';
} 'middleware name is required';

dies_ok {
$client->enable('FOOBARBAZAWESOMEMIDDLEWARE');
}, 'middleware should be loadable';
} 'middleware should be loadable';

dies_ok {
$client->enable_if('Format::JSON');
}, 'enable if require a coderef';
} 'enable if require a coderef';

$client->enable('Dummy');
is scalar @{$client->middlewares}, 1, 'middleware dummy added';
Expand Down

0 comments on commit f61a039

Please sign in to comment.