metacpan / MetaCPAN-Client

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

# the following is the same as ->author('MICKEY') #12

Closed kevindawson closed 10 years ago

kevindawson commented 10 years ago

not true

my $mcpan  = MetaCPAN::Client->new();

try{
    my $author = $mcpan->author('BOWTIE');
    p $author; # MetaCPAN::Client::Author
};

try{
    my $author = $mcpan->author( { pauseid => 'BOWTIE'} );
    p $author; # MetaCPAN::Client::ResultSet
};

produces the following

kevin@billy:~/scratch/svn2git/script$ perl authors-02.pl 
Printing in line 23 of authors-02.pl:
MetaCPAN::Client::Author  {
    Parents       Moo::Object
    public methods (14) : blog, city, country, dir, email, gravatar_url, name, new, pauseid, profile, releases, updated, user, website
    private methods (1) : _known_fields
    internals: {
        data   {
            blog           [
                [0] {
                    feed   "",
                    url    "http://kevindawson.github.io/bowtie/"
                }
            ],
            country        "GB",
            dir            "id/B/BO/BOWTIE",
            email          [
                [0] "bowtie@cpan.org"
            ],
            gravatar_url   "https://secure.gravatar.com/avatar/9f27e15605c9a2d35a4f307a0bbf5dbf?s=130&d=identicon",
            name           "Kevin Dawson",
            pauseid        "BOWTIE",
            profile        [
                [0] {
                    id     "kevindawson",
                    name   "coderwall"
                },
                [1] {
                    id     "kevindawson",
                    name   "github"
                },
                [2] {
                    id     "BOWTIE",
                    name   "github-meets-cpan"
                },
                [3] {
                    id     "bowtie",
                    name   "ohloh"
                }
            ],
            updated        "2013-07-31T10:24:57",
            user           "m-AM5x8ZSAmcmUZCGkQVTA",
            website        []
        }
    }
}
Printing in line 28 of authors-02.pl:
MetaCPAN::Client::ResultSet  {
    Parents       Moo::Object
    public methods (9) : BUILDARGS, facets, has_scroller, items, new, next, scroller, total, type
    private methods (0)
    internals: {
        scroller   Search::Elasticsearch::Scroll,
        total      1,
        type       "author"
    }
}

they are not the same to me as I can not extract email from both or from the following

my $author = $mcpan->author({name => 'Kevin Dawson',});
tsibley commented 10 years ago

I believe the point is that the search query is the same.

You can access the email address from either:

use MetaCPAN::Client;
use DDP;
use Try::Tiny;

my $mcpan  = MetaCPAN::Client->new();

try{
    my $author = $mcpan->author('BOWTIE');
    p $author->email; # MetaCPAN::Client::Author
};

try{
    my $author = $mcpan->author( { pauseid => 'BOWTIE'} );
    p $_->email while $_ = $author->next; # MetaCPAN::Client::ResultSet
};
kevindawson commented 10 years ago

tsibley many thanks for the kick

it might be nice if the pod was extended to include it

tsibley commented 10 years ago

@kevindawson Did you not read the documentation of MetaCPAN::Client::Author or MetaCPAN::Client::ResultSet? That's all I did.

mickeyn commented 10 years ago

@tsibley :+1:

@kevindawson even simpler - follow author documentation on perldoc MetaCPAN::Client

kevindawson commented 10 years ago

tsibley, yes I did read the pod, they are not the same

as for your helpful kick, did it not come from https://metacpan.org/pod/Search::Elasticsearch::Scroll

so as I said before, if you have to use a different technique to extract the data then they are not the same

tsibley commented 10 years ago

@kevindawson No, my "kick" came from reading the documentation of MetaCPAN::Client::Author and MetaCPAN::Client::ResultSet, as I said. The difference between return values for simple and non-simple searches, particularly for ->author, is described here: https://metacpan.org/pod/MetaCPAN::Client#author

And as I said before, "I believe the point is that the search query is the same," and produces the same conceptual results, not that you'd get back the exact same object to work with from the return value.

It's all documented, though I do think it can be clarified even a little bit more. See PR #13.

kevindawson commented 10 years ago

@tsibley thanks for the enlightenment :)