Acme-Insult-Glax

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

You may request specific insults by passing parameters.

Expected parameters include:

- `lang`

    Insult's language style. Expected styles include:

    - `en`

        Plain English. This is the default.

    - `en_corporate`

        English with corporate jargon inserted. Perfect for the 4:50p work email.

- `template`

    Insult template.

    The default value is different depending on the parameters passed to the API:

    - `lang => 'en'`

        ```
        You are as <adjective> as <article target=adj1> <adjective min=1 max=3 id=adj1> <amount> of <adjective min=1 max=3> <animal> <animal_part>
        ```

    - `lang => 'en', who => 'Alex'`

        ```

README.md  view on Meta::CPAN

Generates a single descriptive adjective in plain text.

Expected parameters include:

- `lang`

    Language style. Expected values include:

    - `en`

        Plain English. This is the default.

    - `en_corporate`

        English with corporate jargon inserted.

# 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/Glax.pm  view on Meta::CPAN

    use JSON::Tiny qw[decode_json];
    use URI;
    use parent 'Exporter';
    our %EXPORT_TAGS = ( all => [ our @EXPORT_OK = qw[insult adjective] ] );
    #
    use overload '""' => sub ( $s, $u, $b ) { $s->{insult} // () };
    my $api = URI->new('https://insult.mattbas.org/api/');
    #
    sub _http ( $endpoint, %params ) {
        state $http
            //= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
        ( my $hey = $api->clone )->path( '/api/' . $endpoint . '.json' );
        $hey->query_form(%params);
        my $res = $http->get( $hey->as_string );    # {success} is true even when advice is not found but we'll at least know when we have valid JSON
        $res->{success} ? decode_json( $res->{content} ) : ();
    }
    #
    sub insult (%args) { my $ref = _http( insult => %args ); $ref ? bless $ref, __PACKAGE__ : $ref }

    sub adjective ( $lang //= 'en' ) {
        my $ref = _http( adjective => ( lang => $lang ) );

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

=over

=item C<lang>

Insult's language style. Expected styles include:

=over

=item C<en>

Plain English. This is the default.

=item C<en_corporate>

English with corporate jargon inserted. Perfect for the 4:50p work email.

=back

=item C<template>

Insult template.

The default value is different depending on the parameters passed to the API:

=over

=item C<lang =E<gt> 'en'>

    You are as <adjective> as <article target=adj1> <adjective min=1 max=3 id=adj1> <amount> of <adjective min=1 max=3> <animal> <animal_part>

=item C<lang =E<gt> 'en', who =E<gt> 'Alex'>

    Alex is as <adjective> as <article target=adj1> <adjective min=1 max=3 id=adj1> <amount> of <adjective min=1 max=3> <animal> <animal_part>

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

=over

=item C<lang>

Language style. Expected values include:

=over

=item C<en>

Plain English. This is the default.

=item C<en_corporate>

English with corporate jargon inserted.

=back

=back

=head1 LICENSE & LEGAL



( run in 0.359 second using v1.01-cache-2.11-cpan-8780591d54d )