App-RoboBot

 view release on metacpan or  search on metacpan

doc/conf.py  view on Meta::CPAN


# Output file base name for HTML help builder.
htmlhelp_basename = 'RoboBotdoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',

# Latex figure (float) alignment
#'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples

lib/App/RoboBot/Plugin/Fun/Figlet.pm  view on Meta::CPAN

);

has '+description' => (
    default => 'Provides functions to interact with the external figlet program for generating ASCII-art style text banners.',
);

=head2 figlet

=head3 Description

Given a font name and a string, returns a multi-line string containing the
generated figlet.

=head3 Usage

<font name> <string>

=head3 Examples

    :emphasize-lines: 2-6

    (figlet small robobot)
             _         _         _
     _ _ ___| |__  ___| |__  ___| |_
    | '_/ _ \ '_ \/ _ \ '_ \/ _ \  _|
    |_| \___/_.__/\___/_.__/\___/\__|

=head2 figlet-fonts

=head3 Description

Returns a list of the figlet fonts available.

=cut

has '+commands' => (
    default => sub {{
        'figlet' => { method      => 'figlet_convert',
                      description => 'Given a font name and a string, returns a multi-line string containing the generated figlet.',
                      usage       => '<font name> <string>', },

        'figlet-fonts' => { method      => 'figlet_fonts',
                            description => 'Returns a list of the figlet fonts available.', },
    }},
);

sub figlet_convert {
    my ($self, $message, $command, $rpl, $font, @args) = @_;

    unless (defined $font) {
        $message->response->raise('Must supply a valid font name. See (figlet-fonts) for the available fonts.');
        return;
    }

    my $string = join(' ', @args);

    unless (defined $string && length($string) > 0) {
        $message->response->raise('Must supply a string to figlet-ize.');
        return;
    }

    my @figlet;
    my $shortest_ws = 1_000;

    open(my $fh, '-|', '/usr/bin/figlet', '-l', '-w', 120, '-f', $font, $string) or return;
    while (my $ln = <$fh>) {
        chomp($ln);
        if ($ln =~ m{^(\s*)}) {
            $shortest_ws = length($1) if defined $1 && length($1) < $shortest_ws;
        }
        push(@figlet, $ln);
    }
    close($fh);

    @figlet = grep { $_ =~ m{\S+} } @figlet;

    if (@figlet > 6) {
        $message->response->raise('Generated figlet contains too many lines. Please try a shorter string or a different font.');
        return;
    }

    if ($shortest_ws > 0) {
        @figlet = map { substr($_, $shortest_ws) } @figlet;
    }

    if (grep { length($_) > 100 } @figlet) {
        $message->response->raise('Generated figlet is too wide. Please try a shorter string or a different font.');
        return;
    }

    return join("\n", @figlet);
}

sub figlet_fonts {
    my ($self, $message, $command, $rpl) = @_;

    my @fonts;

    opendir(my $dirh, '/usr/share/figlet') or return;
    while (my $fn = readdir($dirh)) {
        if ($fn =~ m{^(.+)\.flf}) {
            push(@fonts, $1);
        }
    }
    closedir($dirh);

    return sort { $a cmp $b } @fonts;
}

__PACKAGE__->meta->make_immutable;

1;

share/ubuntu-xenial-16.04-cloudimg-console.log  view on Meta::CPAN

[  OK  ] Started Flush Journal to Persistent Storage.
         Starting udev Kernel Device Manager...
[  OK  ] Started udev Kernel Device Manager.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Monitoring of LVM2 mirrors,...ng dmeventd or progress polling.
[  OK  ] Reached target Local File Systems (Pre).
[  OK  ] Reached target Local File Systems.
         Starting Commit a transient machine-id on disk...
         Starting LSB: AppArmor initialization...
         Starting Create Volatile Files and Directories...
         Starting Set console font and keymap...
         Starting Tell Plymouth To Write Out Runtime Data...
[  OK  ] Started Create Volatile Files and Directories.
[  OK  ] Started Commit a transient machine-id on disk.
[  OK  ] Started Tell Plymouth To Write Out Runtime Data.
[  OK  ] Reached target System Time Synchronized.
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Found device /dev/ttyS0.
[  OK  ] Started Update UTMP about System Boot/Shutdown.
[  OK  ] Listening on Load/Save RF Kill Switch Status /dev/rfkill Watch.
[   17.257594] cloud-init[452]: Cloud-init v. 0.7.8 running 'init-local' at Mon, 12 Dec 2016 02:27:55 +0000. Up 16.50 seconds.
[  OK  ] Started Initial cloud-init job (pre-networking).
[  OK  ] Started LSB: AppArmor initialization.
[  OK  ] Reached target Network (Pre).
         Starting Raise network interfaces...
[  OK  ] Started Set console font and keymap.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Started Raise network interfaces.
         Starting Initial cloud-init job (metadata service crawler)...
[  OK  ] Reached target Network.
[   19.915021] cloud-init[1020]: Cloud-init v. 0.7.8 running 'init' at Mon, 12 Dec 2016 02:27:58 +0000. Up 19.25 seconds.
[   19.941125] cloud-init[1020]: ci-info: +++++++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++++++++
[   19.951334] cloud-init[1020]: ci-info: +--------+------+----------------------------+---------------+-------+-------------------+
[   19.958263] cloud-init[1020]: ci-info: | Device |  Up  |          Address           |      Mask     | Scope |     Hw-Address    |
[   19.962257] cloud-init[1020]: ci-info: +--------+------+----------------------------+---------------+-------+-------------------+
[   19.973650] cloud-init[1020]: ci-info: | enp0s3 | True |         10.0.2.15          | 255.255.255.0 |   .   | 02:f3:d6:4a:16:a4 |



( run in 1.727 second using v1.01-cache-2.11-cpan-ceb78f64989 )