metacpan / MetaCPAN-Client

Home of the official MetaCPAN Perl API client.
21 stars 23 forks source link

->modules query prematurely flattens to scalar #43

Closed kentfredric closed 8 years ago

kentfredric commented 8 years ago

The following code worked prior to the ES upgrade.

#!perl
use strict;
use warnings;

use MetaCPAN::Client;

my $name   = 'AcePerl-1.92';
my $author = 'LDS';
my $client = MetaCPAN::Client->new();

my $iterator = $client->module(
  {
    all => [
      { release    => $name },                          #
      { author     => $author },
      { authorized => 1 },
      { indexed    => 1 },                              #
      { mime       => 'text/x-script.perl-module' },    #
    ]
  }
);

while ( my $result = $iterator->next ) {
  next unless $result->module;
  for my $module (@{ $result->module }) {
    printf "%s\n", $module->{name};
  }
}

On 1.020000 this specific logic works as expected. On 1.021000, it gets confused at some point and bails quite early as $result->module no longer returns an arrayref.

mickeyn commented 8 years ago

Fixed in https://v1.metacpan.org/release/MICKEY/MetaCPAN-Client-1.022000-TRIAL

also, I'd recommend this small change to the code:

my $client = MetaCPAN::Client->new( version => "v1" );

Please check the trial version and I'll try to release it by the end of the weekend.

kentfredric commented 8 years ago

Works for me :) :heart: