Skip to content

Commit

Permalink
Merge pull request #419 from CPAN-API/uri-escape-rt-bug-source
Browse files Browse the repository at this point in the history
URI-escape rt bugs source url
  • Loading branch information
oalders committed Aug 19, 2015
2 parents 2978c68 + 580ac63 commit d3ef422
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/MetaCPAN/Script/Tickets.pm
Expand Up @@ -13,6 +13,7 @@ use Log::Contextual qw( :log :dlog );
use Moose;
use Parse::CSV;
use Pithub;
use URI::Escape qw(uri_escape);

with 'MetaCPAN::Role::Script', 'MooseX::Getopt';

Expand Down Expand Up @@ -172,6 +173,7 @@ sub retrieve_rt_bugs {

log_error { $resp->status_line } unless $resp->is_success;

# NOTE: This is sending a byte string.
return $self->parse_tsv( $resp->content );
}

Expand All @@ -180,6 +182,7 @@ sub parse_tsv {
$tsv =~ s/^#\s*(dist\s.+)/$1/m; # uncomment the field spec for Parse::CSV
$tsv =~ s/^#.*\n//mg;

# NOTE: This is byte-oriented.
my $tsv_parser = Parse::CSV->new(
handle => IO::String->new($tsv),
sep_char => "\t",
Expand All @@ -190,8 +193,7 @@ sub parse_tsv {
while ( my $row = $tsv_parser->fetch ) {
$summary{ $row->{dist} } = {
type => 'rt',
source => 'https://rt.cpan.org/Public/Dist/Display.html?Name='
. $row->{dist},
source => $self->rt_dist_url( $row->{dist} ),
active => $row->{active},
closed => $row->{inactive},
map { $_ => $row->{$_} + 0 }
Expand All @@ -203,6 +205,12 @@ sub parse_tsv {
return \%summary;
}

sub rt_dist_url {
my ( $self, $dist ) = @_;
return 'https://rt.cpan.org/Public/Dist/Display.html?Name='
. uri_escape($dist);
}

__PACKAGE__->meta->make_immutable;

1;
46 changes: 46 additions & 0 deletions t/release/text-tabs-wrap.t
@@ -0,0 +1,46 @@
use Test::More;
use strict;
use warnings;

use lib 't/lib';
use MetaCPAN::TestHelpers;

test_distribution(
'Text-Tabs+Wrap',
{
bugs => {
type => 'rt',
source =>
'https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Tabs%2BWrap',
new => 2,
open => 0,
stalled => 0,
patched => 0,
resolved => 15,
rejected => 1,
active => 2,
closed => 16,
},
},
'rt url is uri escaped',
);

test_release(
{
name => 'Text-Tabs+Wrap-2013.0523',

distribution => 'Text-Tabs+Wrap',

author => 'LOCAL',
authorized => \1,
first => \1,
version => '2013.0523',

# No modules.
status => 'cpan',

provides => [],
}
);

done_testing;
1 change: 1 addition & 0 deletions t/var/fakecpan/bugs.tsv
Expand Up @@ -3,3 +3,4 @@
Monkey-Patch 0 0 0 0 1 0 0 1
Moo 2 5 0 0 2 1 7 3
Moose 15 20 4 0 122 23 39 145
Text-Tabs+Wrap 2 0 0 0 15 1 2 16
7 changes: 7 additions & 0 deletions t/var/fakecpan/configs/text-tabs+wrap-2013.0523.yml
@@ -0,0 +1,7 @@
name: Text-Tabs+Wrap
version: 2013.0523
provides: {}

X_Module_Faker:
omitted_files:
- META.json

0 comments on commit d3ef422

Please sign in to comment.