Docker-Names-Random

 view release on metacpan or  search on metacpan

lib/Docker/Names/Random.pm  view on Meta::CPAN

    my $r_for_adj = int( rand( scalar @{ $data->{'adjectives'} } ) );
    $adj = $data->{'adjectives'}->[$r_for_adj]->{'word'};
    my $r_for_name = int( rand( scalar @{ $data->{'names'} } ) );
    $surname = $data->{'names'}->[$r_for_name]->{'surname'};

    if ( $adj eq 'boring' && $surname eq 'wozniak' ) {

        # Steve Wozniak is not boring
        goto 'CREATE_NAME';
    }

    return $adj . q{_} . $surname;
}


1;

=pod

=encoding UTF-8

=head1 NAME

Docker::Names::Random - Create random strings like Docker does for container names.

=head1 VERSION

version 0.0.2

=head1 SYNOPSIS

    # As an object (if you create many, this is more efficient).
    require Docker::Names::Random;

    my $dnr = Docker::Names::Random->new();
    my $random_name1 = $dnr->docker_name();

    # As an imported function.
    use Docker::Names::Random qw( docker_name );
    # OR
    use Docker::Names::Random qw( :all );

    my $random_name2 = docker_name();

=head1 DESCRIPTION

If you are using Docker, you may have noticed that it
creates random names for containers when you haven't provided any
specific name. These names are a combination of an adjective
and a proper name of an individual. The individuals are
famous men and women picked from the history of scientific exploration
and engineering.

This package allows you to use the same system in your own programs.
You would get combinations like
I<interesting_mendeleev>,
I<epic_engelbart>,
I<lucid_dhawan>,
I<recursing_cori>,
I<ecstatic_liskov> and
I<busy_ardinghelli>.

The combination I<boring_wozniak> is not allowed because
L<Steve Wozniak|https://en.wikipedia.org/wiki/Steve_Wozniak> is not boring.
This same limitation exists in the
L<original code|https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go>.

=for stopwords overthruster Docker::Names::Random Docker Names Random

=head1 STATUS

This module is currently being developed so changes in the API are possible,
though unlikely.

=head1 METHODS

=head2 new

Create object.

    require Docker::Names::Random;
    my $dnr = Docker::Names::Random->new();

=head2 docker_name

Return a random string.

    my $random_name = $dnr->docker_name();

=head1 FUNCTIONS

=head2 docker_name

Return a random string.

    use Docker::Names::Random qw( docker_name );
    # OR
    use Docker::Names::Random qw( :all );

    my $random_name = docker_name();

=head1 AUTHOR

Mikko Johannes Koivunalho <mikko.koivunalho@iki.fi>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by Mikko Johannes Koivunalho.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

__DATA__
---
adjectives:
- word: admiring
- word: adoring
- word: affectionate
- word: agitated
- word: amazing
- word: angry
- word: awesome
- word: beautiful
- word: blissful
- word: bold
- word: boring
- word: brave
- word: busy
- word: charming
- word: clever
- word: cool
- word: compassionate
- word: competent
- word: condescending
- word: confident
- word: cranky
- word: crazy
- word: dazzling
- word: determined
- word: distracted
- word: dreamy
- word: eager
- word: ecstatic
- word: elastic
- word: elated
- word: elegant
- word: eloquent
- word: epic
- word: exciting
- word: fervent
- word: festive
- word: flamboyant
- word: focused
- word: friendly
- word: frosty
- word: funny
- word: gallant
- word: gifted
- word: goofy
- word: gracious
- word: great
- word: happy
- word: hardcore
- word: heuristic
- word: hopeful
- word: hungry
- word: infallible
- word: inspiring
- word: interesting
- word: intelligent
- word: jolly
- word: jovial
- word: keen
- word: kind
- word: laughing
- word: loving
- word: lucid
- word: magical
- word: mystifying
- word: modest
- word: musing
- word: naughty
- word: nervous
- word: nice
- word: nifty
- word: nostalgic
- word: objective
- word: optimistic



( run in 0.783 second using v1.01-cache-2.11-cpan-39bf76dae61 )