Acme-Insult-Pirate

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


## `insult( [...] )`

Arr! Tear some rogue down.

```perl
my $shade = insult( ); # Random insult
print insult( ); # stringify
```

On success, an insult be returned as a blessed hash reference containin' the followin' data:

- `insult`

    The line ye best be throwin' at a scallywag.

# LICENSE & LEGAL

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License

lib/Acme/Insult/Pirate.pm  view on Meta::CPAN

        state $api //= URI->new('https://pirate.monkeyness.com/api/insult');

        #~ $api->query_form( %params );
        my $res = $http->get($api);    # {success} is true even when advice is not found but we'll at least know when we have valid JSON

        # This API only returns strings for now
        #~ $res->{success} ? decode_json( $res->{content} ) : ();
        $res->{success} ? { insult => $res->{content} } : ();
    }
    #
    sub insult (%args) { my $ref = _http(%args); $ref ? bless $ref, __PACKAGE__ : $ref }
}
1;
__END__

=encoding utf-8

=head1 NAME

Acme::Insult::Pirate - Programmatically Generate Pirate Themed Insults

lib/Acme/Insult/Pirate.pm  view on Meta::CPAN


These functions may be imported by name or wit' the C<:all> tag.

=head2 C<insult( [...] )>

Arr! Tear some rogue down.

    my $shade = insult( ); # Random insult
    print insult( ); # stringify

On success, an insult be returned as a blessed hash reference containin' the followin' data:

=over

=item C<insult>

The line ye best be throwin' at a scallywag.

=back

=head1 LICENSE & LEGAL

t/00_compile.t  view on Meta::CPAN

#
my $insult = insult();
#
{
    my $TODO = todo 'the pirate back end is way too fragile' unless +$insult;
    ok + $insult, 'stringify';
    #
    is my $insult = Acme::Insult::Pirate::insult(), hash {
        field insult => D();
    }, 'hash (fake)';
    isa_ok $insult, ['Acme::Insult::Pirate'], 'insults are blessed hashes';
};
#
done_testing;



( run in 1.067 second using v1.01-cache-2.11-cpan-de7293f3b23 )