## dist_cpan-HANENKAMP-Net-SMTP-Client-Async.md
# NAME

Net::SMTP::Client::Async - asynchronous communication client for SMTP

# SYNOPSIS

```
use Net::SMTP::Client::Async;

with await Net::SMTP::Client::Async.connect(:host<smtp.gmail.com>, :port(465), :secure) {
    await .hello;

    my $message = q:to/END_OF_MESSAGE/;
    To: Sterling <hanenkamp@cpan.org>
    From: Sterling <hanenkamp@cpan.org>
    Subject: Hello World

    Goodbye.
    END_OF_MESSAGE

    await .send-message(
        from => "hanenkamp@cpan.org",
        to   => [ "hanenkamp@cpan.org" ],
        :$message,
    );

    .quit;

    CATCH {
        when X::Net::SMTP::Client::Async {
            note "Unable to send email message: $_";
            .quit
        }
    }
}

```

# DESCRIPTION

This is an SMTP client library written using asynchronous methods. This class provides two interfaces:

* **Simple Message Sending API**. A high-level interface is provided for doing the initial connection handshake, sending a message, and quitting. This is probably the usual use of this library where you just want to send an email message to an SMTP server.
* **Complete Low Level API**. A low-level interface is provided that gives you direct access to any command you want to send to an SMTP server. It also provides low-level access to the responses from the SMTP server.

These interfaces are completely interchangeable and can be interleaved.

For example, consider this program which will connect to an ESMTP server on port 587, upgrade a plaintext connection to TLS and then send a message:

```
use Net::SMTP::Client::Async;

my $smtp = Net::SMTP::Client::Async.connect(
    :host<smtp.gmail.com>, :port(587),
);

await $smtp.hello;
await $smtp.start-tls(:host<smtp.gmail.com>);

# After TLS, you must say hello again.
await $smtp.hello;

await $smtp.send-message(
    from    => "hanenkamp@cpan.org",
    to      => [ "hanenkamp@cpan.org" ],
    message => q:to/END_OF_MESSAGE/,
        To: Sterling <hanenkamp@cpan.org>
        From: Sterling <hanenkamp@cpan.org>
        Subject: Hello World

        Goodbye.
        END_OF_MESSAGE
);

$smtp.quit;

CATCH {
    when X::Net::SMTP::Client::Async {
        note "Unable to send email message: $_";
        .quit
    }
}

```

Now consider a similar program, but written solely using the low-level interface API:

```
use Net::SMTP::Client::Async;

my $smtp = Net::SMTP::Client::Async.connect(
    :host<smtp.gmail.com>, :port(587),
);

my $ehlo = await $smtp.EHLO('localhost.localdomain');

die "unable to perform SMTP handshake" if $ehlo.is-error;

$smtp.populate-keywords($ehlo.text);

die "STARTTLS is not supported by SMTP server" unless $smtp.keywords<STARTTLS>;

my $start-tls = await $smtp.STARTTLS;
die "unable to perform upgrade to secure SMTP connection" if $start-tls.is-error;

$smtp.clear-keywords;

my $upgrade = try {
    await $smtp.upgrade-client(:host<smtp.gmail.com>);

    CATCH {
        default {
            die "unable to negotiate SSL upgrade with client";
        }
    }
}

my $ehlo-again = await $smtp.EHLO('localhost.localdomain');
die "unable to perform secure SMTP handshake" if $ehlo-again.is-error;

$smtp.populate-keywords($ehlo-again.text);

my $mail = await $smtp.MAIL('hanenkamp@cpan.org');
die "unable to send mail FROM hanenkamp@cpan.org" if $mail.is-error;

my $rcpt = await $smtp.RCPT('hanenkamp@cpan.org');
die "unable to send mail TO hanenkamp@cpan.org" if $rcpt.is-error;

my $data = await $smtp.DATA;
die "unable to initiate message send" if $data.is-error;

# perform dot-stuffing of the message
my $message = $smtp.escape-message(q:to/END_OF_MESSAGE/);
    To: Sterling <hanenkamp@cpan.org>
    From: Sterling <hanenkamp@cpan.org>
    Subject: Hello World

    Goodbye.
    END_OF_MESSAGE

my $message-response = await $smtp.send-raw-message($message);

$smtp.QUIT;
$smtp.disconnect;

```

These programs are not equivalent as the high-level methods perform additional error checking and such that is not being deon in the second program. However, the second program illustrates what is possible.

Aside from the change in interface, the greatest difference between the high-level and low-level APIs is that the high-level API provides errors through `X::Net::SMTP::Client::Async` exceptions. The low-level API, on the other hand does no error checking and leaves it to the developer to do the error checking. You can do that by looking at the returned `Net::SMTP::Client::Async::Response` and checking the details of that response, which includes the response code, the full text of the response (which may span multiple lines for some commands, but has the code parts at the start of every line removed), and some convenience methods for detecting success and errors.

The only exception to the no error checking rule is the [.upgrade-client](#method upgrade-client) method. This is due to the fact that this is a call-out to the method with the same name in IO::Socket::Async::SSL, which passes SSL exception from failed SSL negotiation through to the caller.

Another difference between the high-level and low-level interfaces is that the high-level interface guarantees thread safety. The high-level interface works to keep the object and connection consistent and prevents the state from being corrupted across threads. The low-level interface provides fewer guarantees.

For example, consider the situation where you use [.STARTTLS](#method STARTTLS) to request SSL negotiation and receive a favorable 250 code response. However, you then call another method other than `.upgrade-client`. If you do that, your client will be in the wrong state compared to the server. On the other hand, this also means you can use features of SMTP that the high-level interface does not implement or permit, which is the primary purpose of the low-level interface.

If you have an SMTP server where you need to do something that takes you off the beaten path of sending a fairly simple email message, you should be able to do that with this library.

# CONCURRENCY

This class is intended to be thread safe. However, it is also fairly immature, so there might be some bugs with that.

Internally, any command sent to the SMTP socket is queued up using a <Channel>. This means all commands will be executed in the order they are received. Commands may be sent before the response has been received if you do not make sure to `await` on the previous method call before calling another, which could result in unrecoverable errors. For this reason, it is recommended that you perform an `await` prior to calling another method.

Internal state within the object is protected by a <Lock> using a monitor pattern. The state of the object returned by the accessors will never be partially constructed. However, it is still possible to use the returned state in an unsafe way if a method, which changes state is called. This includes the following methods:

* [.hello](#method hello)
* [.start-tls](#method start-tls)
* [.upgrade-client](#method upgrade-client)

Other methods may also change state. Those changes are clearly documented in each method's documentation.

Additional precautions should be taken around the calls of these methods or any state-changing methods to make sure that the operation is complete *before* accessing the attributes of the method. Otherwise, you *will* end up with thread safety problems.

# METHODS

## method socket

```
has $.socket

```

This will be either a IO::Socket::Async or a IO::Socket::Async::SSL object which represents the underlying connection to the SMTP server. As long as the object is defined, this will also be defined. After [.quit](#method quit) or [.disconnect](#method disconnect) has been called, though, the object will be in a disconnected state.

## method secure

```
has Bool $.secure = False

```

This flag will be set to `False` if the connection to the SMTP server is a plain text connection or to `True` if the connection is currently secure. It will be set to `True` if the socket is upgraded to use SSL.

## method keywords

```
has %.keywords

```

This hash will be populated after the client has successfully performed an ESMTP handshake during [.hello](#method hello) or by calling [.populate-keywords](#method populate-keywords). If the SMTP object is used to initiate a plaintext connection and then upgraded using [.start-tls](#method start-tls) or clared using [.clear-keywords](#method clear-keywords), these will be cleared again. This is because the ESMTP handshake must be performed again after upgrading the connection to a secure connection as the server may provide different keywords for secure connections than it provides for unsecure connections.

The keywords are typically the name of supported extended commands. The value of the keywords is set to `True` if no parameters are provided. If parameters are provided, then the value of that keyword will be set to the list of those parameters:

```
my $smtp = Net::SMTP::Client::Async.new;
await $smtp.hello;
say "Supports STARTTLS" if $smtp.keywords<STARTTLS>;
say "Supports these SASL plugins: $smtp.keywords<AUTH>.join(', ')" if $smtp.keywords<AUTH>;

```

## method connect

```
multi method connect(IO::Socket::Async $socket --> Promise:D)
multi method connect(IO::Socket::Async::SSL $socket --> Promise:D)
multi method connect(Str :$host, UInt :$port, Bool :$secure --> Promise:D)

```

These are the constructors for Net::SMTP::Client::Async. These establish a connection to the SMTP server or allow the object to adopt a previously established connection to an SMTP server. If an IO::Socket::Async object is given, the [.secure](#method secure) flag will be `False`. If an IO::Socket::Async::SSL object is given, the `.secure` flag will be `True`.

If called with no arguments or called with some combination of `$host`, `$port`, and `$secure`, the constructor will make the connection for you. The default `$host` is `"localhost"`. The default `$port` is 25 if `$secure` is not set or 465 if `$secure` is set. The default value for `$secure` is `False`.

Each of these methods return a <Promise>, which will be fulfilled once the connection has been established and the object constructed. The promise is kept with a Net::SMTP::Client::Async object.

That constructed object will not have performed the initial SMTP handshake. Therefore, you will need to immediately call [.hello](#method hello) or [.EHLO](#method EHLO) or [.HELO](#method HELO) to complete the connection process.

## method hello

```
method hello(Str:D $domain = "localhost.localdomain" --> Promise:D)

```

On success, this method updates the state of this object by either setting or clearing the `keywords`.

This method will attempt to perform an ESMTP handshake (i.e., `EHLO`) with the SMTP server. If that handshake succeeds, it will parse the response and place all the announced keywords and paramters into the [.keywords attribute](#method keywords).

If the ESMTP handshake fails, this method will attempt to fallback on SMTP handshake (i.e., `HELO`). In this case, `.keywords` will remain empty.

The method returns a <Promise>. On failure, the `Promise` will be broken with a [X::Net::SMTP::Client::Async::Handshake](X::Net::SMTP::Client::Async#class X::Net::SMTP::Client::Async::Handshake) exception. On success, the `Promise` is kept with a Net::SMTP::Client::Async::Response containing a successful response.

## method start-tls

```
method start-tls(--> Promise:D)

```

On success, this method updates the state of this object by clearing the `keywords` and setting the `secure` flag to `True`.

This method returns a <Promise>, which will be kept if the operation completes successfully with the Net::SMTP::Client::Async::Response object showing the successful response from the server. If the operation fails to secure the connection by first sending the `STARTTLS` command and then performing a successful SSL negotiation, it will be broken with an exception.

If an ESMTP handshake has not completed or the ESMTP server does not list `STARTTLS` support, the returned `Promise` will be broken with an [X::Net::SMTP::Client::Async::Support](X::Net::SMTP::Client::Async#class X::Net::SMTP::Client::Async::Support) exception.

If the connection is already secure or if the `STARTTLS` command results in an error response, the returned `Promise` will be broken with an [X::Net::SMTP::Client::Async::Secure](x::SMTP::Client::Async#class X::Net::SMTP::Client::Async::Secure) exception.

If the SSL handshake fails, the returned `Promise` will be broken with an exception from OpenSSL.

If the returned `Promise` is broken fro any resonse, the connection to the SMTP server will also be disconnected and the Net::SMTP::Client::Async object is now no longer in a usable state and should be discarded.

## method send-message

```
method send-message(
    Str:D :$from!,
    Str:D :@to!,
    Str:D :$message!,
    --> Promise:D
)

```

This method performs the work required for sending an SMTP message. This means sending the `MAIL` command with the given `$from` address, teh `RCPT` command for each given `@to` address, the `DATA` command to start sending data, and then the `$message` itself followed by a line containing only a ".". The `$message` will have "dot stuffing" performed on it as well.

The method returns a <Promise> which will be kept with the final successful Net::SMTP::Client::Async::Response received after transmitting the message. If any step of the process fails, the returned `Promise` will be broken with the [X::Net::SMTP::Client::Async::Send](X::Net::SMTP::Client::Async#class X::Net::SMTP::Client::Async::Send) exception.

## method quit

```
method quit(--> Promise:D)

```

After this method is called, no other method should be called on this object. The object should now be discarded and cannot be reused.

This sends a `QUIT` command to the SMTP serer and disconnects the socket.

The returned `Promise` will be kept with the result of the Net::SMTP::Client::Async::Result returned by the server after sending teh `QUIT` command.

## method send-command

```
method send-command(Str:D $command, Str $argument? --> Promise:D)

```

This is a low-level method.

This will send any arbitrary command to the SMTP server with the given argument. Nothing special is done to escape or prepare the values sent other than having a space inserted between `$command` and `$argument` (assuming `$argument` is specified at all).

The returned <Promise> will be kept with a Net::SMTP::Client::Async::Response object containing the response from the server for that command. This class will not break the returned `Promies`, so if it is broken, something unexpected has gone wrong.

## method EHLO

```
method EHLO(Str:D $domain --> Promise:D)

```

This is a low-level method.

This will send the `EHLO` command and return a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method populate-keywords

```
multi method populate-keywords(Net::SMTP::Client::Async::Response:D $text)
multi method populate-keywords(Str:D $text)

```

This is a low-level method.

This will set the [.keywords](#method keywords) attribute to the keywords found in the message. If passed as a string, it should be text the format returned by Net::SMTP::Client::Async::Response by the `.text` method.

## method clear-keywords

```
method clear-keywords()

```

This is a low-level method.

This will clear the [.keywords](#method keywords) attribute. This should be called when the capabilities of the SMTP server were previously known, but now are not. (I.e., after `STARTTLS`).

## method HELO

```
method HELO(Str:D $domain --> Promise:D)

```

This is a low-level method.

This will send the `HELO` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method MAIL

```
method MAIL(Str:D $from --> Promise:D)

```

This is a low-level method.

This will send the `MAIL` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

The `$from` argument will have the "FROM:" prefix added to it automatically before being sent to the SMTP server.

## method RCPT

```
method RCPT(Str:D $to --> Promise:D)

```

This is a low-level method.

This will send the `RCPT` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

The `$to` argument will have the "TO:" prefix added to it automatically before being sent to the SMTP server.

## method DATA

```
method DATA(--> Promise:D)

```

This is a low-level method.

This will send the `DATA` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method escape-message

```
method escape-message(Str:D $message --> Str:D)

```

This is a low-level method.

You only need this if you are using [.send-raw-message](#method send-raw-message). This performs "dot stuffing" on the given string. That is, SMTP uses a line containing a single period to mark the end of a message. In order to make sure that users never see this, the SMTP server will ignore the first period that starts any line that contains any text other than a single period. Therefore, dot stuffing is the process of escaping any line that starts with a period by adding an additional period to the start of those lines.

The string returned byt this method will have an extra period added to any line that starts with a period.

## method send-raw-message

```
method send-raw-message(Str:D $raw-message --> Promise:D)

```

This is a low-level method.

This will send message content to the SMTP server followed by a ".". This will not perform any "dot stuffing" on the message. See [.escape-message](#method escape-message).

This will return a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method RSET

```
method RSET(--> Promise:D)

```

This is a low-level method.

This will send the `RSET` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method SEND

```
method SEND(Str:D $from --> Promise:D)

```

This is a low-level method.

This will send the `SEND` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method SOML

```
method SOML(Str:D $from --> Promise:D)

```

This is a low-level method.

This will send the `SOML` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method SAML

```
method SAML(Str:D $from --> Promise:D)

```

This is a low-level method.

This will send the `SAML` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method VRFY

```
method VRFY(Str:D $string --> Promise:D)

```

This is a low-level method.

This will send the `VRFY` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method EXPN

```
method EXPN(Str:D $string --> Promise:D)

```

This is a low-level method.

This will send the `EXPN` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method HELP

```
method HELP(Str:D $string? --> Promise:D)

```

This is a low-level method.

This will send the `HELP` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method NOOP

```
method NOOP(--> Promise:D)

```

This is a low-level method.

This will send the `NOOP` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method QUIT

```
method QUIT(--> Promise:D)

```

This is a low-level method.

This will send the `QUIT` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method disconnect

```
method disconnect(--> Promise:D)

```

This is a low-level method.

Normally, to close your connection, you should issue a call to the [.quit](#method quit) method. This closes the connection to the SMTP server without issuing a `QUIT` command. It also makes sure any internally queued actions stop working.

After this method has been called, the object is in an unusable state and should be discarded.

## method TURN

```
method TURN(--> Promise:D)

```

This is a low-level method.

This will send the `TURN` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method STARTTLS

```
method STARTTLS(--> Promise:D)

```

This is a low-level method.

This will send the `STARTTLS` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method upgrade-client

```
method upgrade-client(*%passthru --> Promise:D)

```

This is a low-level method.

This upgrades the current socket from IO::Socket::Async to IO::Socket::Async::SSL. All arguments are passed through to the `.upgrade-client` method of IO::Socket::Async::SSL.

## method ETRN

```
method ETRN(Str:D $node-name --> Promise:D)

```

This is a low-level method.

This will send the `ETRN` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method AUTH

```
method AUTH(Str:D $mechanism --> Promise:D)

```

This is a low-level method.

This will send the `AUTH` command and returns a <Promise> that will be kept with a Net::SMTP::Client::Async::Response.

## method send-raw

```
method send-raw(Str:D $string --> Promise:D)

```

This is a low-level method.

This queues a data send of the given string. The string is passed through, as is. The method returns a <Promise> which will be kept with a `True`, but makes no guarantee that the send has actually occurred. If you need that, then you need to work directly with the [.socket](#method socket) itself.

## method receive-raw

```
method receive-raw(--> Promise:D)

```

This is a low-level method.

This will return a <Promise> that will be kept with a Net::SMTP::Client::Async::Response containing the next response sent by the SMTP server.


## dist_cpan-TITSUKI-Chart-Gnuplot.md
[![Actions Status](https://github.com/titsuki/raku-Chart-Gnuplot/workflows/test/badge.svg)](https://github.com/titsuki/raku-Chart-Gnuplot/actions)

# NAME

Chart::Gnuplot - A Raku bindings for gnuplot

# SYNOPSIS

### SOURCE

```
use Chart::Gnuplot;
use Chart::Gnuplot::Subset;
my $gnu = Chart::Gnuplot.new(:terminal("png"), :filename("histogram.png"));

my @data = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
Year Male Female
1950 100 90
1960 100 90
1970 80 70
1980 130 140
1990 140 120
2000 200 210
2010 240 230
2020 400 420
EOF

my ($header, *@body) = @data;

$gnu.command("set style histogram clustered");
$gnu.legend(:left);
my AnyTicsTic @tics = (@body>>.[0]).pairs.map(-> (:key($pos), :value($year)) { %(:label($year), :pos($pos)) });
$gnu.xtics(:tics(@tics));
$gnu.xlabel(:label($header[0]));
$gnu.plot(:vertices(@body), :using([2]), :style("histogram"), :title($header[1]), :fill("solid 1.0"));
$gnu.plot(:vertices(@body), :using([3]), :style("histogram"), :title($header[2]), :fill("solid 1.0"));

$gnu.dispose;

```

### OUTPUT

![histogram](histogram.png)

# DESCRIPTION

Chart::Gnuplot is a Raku naive bindings for gnuplot. Chart::Gnuplot runs `gnuplot` using `Proc::Async` and enables you to plot chart or graph with Rakuish interface.

## SUBSET

Defined as:

```
subset FalseOnly of Bool is export where { $_ ~~ Bool:U or $_ === False };
subset TrueOnly of Bool is export where { $_ ~~ Bool:U or $_ === True};
subset LabelRotate of Cool is export where { $_ ~~ Cool:U or $_ ~~ Real or $_ === False };
subset AnyLabelRotate of Cool is export where { $_ ~~ Cool:U or $_ eq "parallel" or $_ ~~ Real or $_ === False };
subset LegendMax of Cool is export where { $_ ~~ Cool:U or $_ eq "auto" or $_ ~~ Real };
subset AnyTicsRotate of Cool is export where { $_ ~~ Cool:U or $_ ~~ Real or $_ === False };
subset AnyTicsOffset of Mu is export where { $_ ~~ Mu:U or $_ ~~ FalseOnly or ($_ ~~ List and $_.all ~~ Pair|Real) };
subset AnyTicsTic of Mu is export where { $_ ~~ Mu:U or $_ ~~ Hash and .<label>:exists and .<pos>:exists and .keys.grep(* eq "label"|"pos"|"level").elems == .keys.elems };

```

## METHODS

### terminal

Defined as:

```
method terminal($terminal)

```

Tells gnuplot what kind of output to generate.

### plot

Defined as:

```
multi method plot(
        :$title, :$ignore, :@range, :@vertices!, :$smooth,
        :@using,
        Str :$style, :ls(:$linestyle), :lt(:$linetype), :lw(:$linewidth), :lc(:$linecolor),
        :pt(:$pointtype), :ps(:$pointsize), :$fill, FalseOnly :$hidden3d, FalseOnly :$contours,
        FalseOnly :$surface, :$palette,
        :&writer? = -> $msg { self.command: $msg }
)

multi method plot(
      :$title, :$ignore, :@range, :$function!, :$smooth,
      Str :$style, :ls(:$linestyle), :lt(:$linetype), :lw(:$linewidth), :lc(:$linecolor),
      :pt(:$pointtype), :ps(:$pointsize), :$fill, FalseOnly :$hidden3d, FalseOnly :$contours,
      FalseOnly :$surface, :$palette,
      :&writer? = -> $msg { self.command: $msg }
)

```

Draws a 2-dimensional plot.

### splot

Defined as:

```
multi method splot(
      :@range,
      :@vertices!, :$smooth,
      :$binary, :$matrix, :$index, :$every,
      :$title, :$style, :ls(:$linestyle), :lt(:$linetype), :lw(:$linewidth), :lc(:$linecolor),
      :$pointtype, :$pointsize, :$fill, FalseOnly :$hidden3d, FalseOnly :$contours,
      FalseOnly :$surface, :$palette, :&writer? = -> $msg { self.command: $msg }
)

multi method splot(
      :@range,
      :$function!, :$smooth,
      :$title, :$style, :ls(:$linestyle), :lt(:$linetype), :lw(:$linewidth), :lc(:$linecolor),
      :$pointtype, :$pointsize, :$fill, FalseOnly :$hidden3d, FalseOnly :$contours,
      FalseOnly :$surface, :$palette, :&writer? = -> $msg { self.command: $msg }
)

```

Draws a 3-dimensional plot.

### label

Defined as:

```
method label(
       :$tag, Str :$label-text, :$at, TrueOnly :$left, TrueOnly :$center, TrueOnly :$right,
       LabelRotate :$rotate, :$font-name, :$font-size, FalseOnly :$enhanced,
       TrueOnly :$front, TrueOnly :$back, :$textcolor, FalseOnly :$point, :$line-type, :$point-type, :$point-size, :$offset,
       TrueOnly :$boxed, TrueOnly :$hypertext, :&writer? = -> $msg { self.command: $msg }
)

```

Places the text string at the corresponding 2D or 3D position.

### xlabel

Defined as:

```
method xlabel(
       Str :$label, :$offset, :$font-name, :$font-size, :$textcolor,
       Bool :$enhanced, AnyLabelRotate :$rotate, :&writer? = -> $msg { self.command: $msg }
)

```

Sets the x-axis label.

### ylabel

Defined as:

```
method ylabel(
       Str :$label, :$offset, :$font-name, :$font-size, :$textcolor,
       Bool :$enhanced, AnyLabelRotate :$rotate, :&writer? = -> $msg { self.command: $msg }
)

```

Sets the y-axis label.

### zlabel

Defined as:

```
method zlabel(
       Str :$label, :$offset, :$font-name, :$font-size, :$textcolor,
       Bool :$enhanced, AnyLabelRotate :$rotate, :&writer? = -> $msg { self.command: $msg }
)

```

Sets the z-axis label.

### x2label

Defined as:

```
method x2label(
       Str :$label, :$offset, :$font-name, :$font-size, :$textcolor,
       Bool :$enhanced, AnyLabelRotate :$rotate, :&writer? = -> $msg { self.command: $msg }
)

```

Sets the x2-axis label.

### y2label

Defined as:

```
method y2label(
       Str :$label, :$offset, :$font-name, :$font-size, :$textcolor,
       Bool :$enhanced, AnyLabelRotate :$rotate, :&writer? = -> $msg { self.command: $msg }
)

```

Sets the y2-axis label.

### cblabel

Defined as:

```
method cblabel(
       Str :$label, :$offset, :$font-name, :$font-size, :$textcolor,
       Bool :$enhanced, AnyLabelRotate :$rotate, :&writer? = -> $msg { self.command: $msg }
)

```

Sets the cb-axis label.

### xrange

Defined as:

```
multi method xrange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method xrange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the horizontal range that will be displayed.

### yrange

Defined as:

```
multi method yrange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method yrange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the vertical range that will be displayed.

### zrange

Defined as:

```
multi method zrange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method zrange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the range that will be displayed on the z axis.

### x2range

Defined as:

```
multi method x2range(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method x2range(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the range that will be displayed on the x2 axis.

### y2range

Defined as:

```
multi method y2range(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method y2range(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the range that will be displayed on the y2 axis.

### cbrange

Defined as:

```
multi method cbrange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method cbrange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the range of values which are colored.

### rrange

Defined as:

```
multi method rrange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method rrange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the range that will be displayed on the r axis.

### trange

Defined as:

```
multi method trange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method trange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Sets the parametric range used to compute x and y values when in parametric or polar modes.

### urange

Defined as:

```
multi method urange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method urange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Set the parametric ranges used to compute x, y, and z values when in splot parametric mode.

### vrange

Defined as:

```
multi method vrange(
      :$min, :$max, Bool :$reverse, Bool :$writeback, Bool :$extend,
      :&writer? = -> $msg { self.command: $msg }
)

multi method vrange(TrueOnly :$restore, :&writer? = -> $msg { self.command: $msg })

```

Set the parametric ranges used to compute x, y, and z values when in splot parametric mode.

### xtics

Defined as:

```
method xtics(
       TrueOnly :$axis, TrueOnly :$border, Bool :$mirror,
       TrueOnly :$in, TrueOnly :$out, TrueOnly :$scale-default, :$scale-major, :$scale-minor, AnyTicsRotate :$rotate, AnyTicsOffset :$offset,
       TrueOnly :$left, TrueOnly :$right, TrueOnly :$center, TrueOnly :$autojustify,
       TrueOnly :$add,
       TrueOnly :$autofreq,
       :$incr,
       :$start, :$end,
       :@tics where Array[AnyTicsTic] | Array[],
       :$format, :$font-name, :$font-size, Bool :$enhanced,
       TrueOnly :$numeric, TrueOnly :$timedate, TrueOnly :$geographic,
       TrueOnly :$rangelimited,
       :$textcolor, :&writer? = -> $msg { self.command: $msg }
)

```

Controls the major (labeled) tics on the x axis.

### ytics

Defined as:

```
method ytics(
       TrueOnly :$axis, TrueOnly :$border, Bool :$mirror,
       TrueOnly :$in, TrueOnly :$out, TrueOnly :$scale-default, :$scale-major, :$scale-minor, AnyTicsRotate :$rotate, AnyTicsOffset :$offset,
       TrueOnly :$left, TrueOnly :$right, TrueOnly :$center, TrueOnly :$autojustify,
       TrueOnly :$add,
       TrueOnly :$autofreq,
       :$incr,
       :$start, :$end,
       :@tics where Array[AnyTicsTic] | Array[],
       :$format, :$font-name, :$font-size, Bool :$enhanced,
       TrueOnly :$numeric, TrueOnly :$timedate, TrueOnly :$geographic,
       TrueOnly :$rangelimited,
       :$textcolor, :&writer? = -> $msg { self.command: $msg }
)

```

Controls the major (labeled) tics on the y axis.

### ztics

Defined as:

```
method ztics(
       TrueOnly :$axis, TrueOnly :$border, Bool :$mirror,
       TrueOnly :$in, TrueOnly :$out, TrueOnly :$scale-default, :$scale-major, :$scale-minor, AnyTicsRotate :$rotate, AnyTicsOffset :$offset,
       TrueOnly :$left, TrueOnly :$right, TrueOnly :$center, TrueOnly :$autojustify,
       TrueOnly :$add,
       TrueOnly :$autofreq,
       :$incr,
       :$start, :$end,
       :@tics where Array[AnyTicsTic] | Array[],
       :$format, :$font-name, :$font-size, Bool :$enhanced,
       TrueOnly :$numeric, TrueOnly :$timedate, TrueOnly :$geographic,
       TrueOnly :$rangelimited,
       :$textcolor, :&writer? = -> $msg { self.command: $msg }
)

```

Controls the major (labeled) tics on the z axis.

### x2tics

Defined as:

```
method x2tics(
       TrueOnly :$axis, TrueOnly :$border, Bool :$mirror,
       TrueOnly :$in, TrueOnly :$out, TrueOnly :$scale-default, :$scale-major, :$scale-minor, AnyTicsRotate :$rotate, AnyTicsOffset :$offset,
       TrueOnly :$left, TrueOnly :$right, TrueOnly :$center, TrueOnly :$autojustify,
       TrueOnly :$add,
       TrueOnly :$autofreq,
       :$incr,
       :$start, :$end,
       :@tics where Array[AnyTicsTic] | Array[],
       :$format, :$font-name, :$font-size, Bool :$enhanced,
       TrueOnly :$numeric, TrueOnly :$timedate, TrueOnly :$geographic,
       TrueOnly :$rangelimited,
       :$textcolor, :&writer? = -> $msg { self.command: $msg }
)

```

Controls the major (labeled) tics on the x2 axis.

### y2tics

Defined as:

```
method y2tics(
       TrueOnly :$axis, TrueOnly :$border, Bool :$mirror,
       TrueOnly :$in, TrueOnly :$out, TrueOnly :$scale-default, :$scale-major, :$scale-minor, AnyTicsRotate :$rotate, AnyTicsOffset :$offset,
       TrueOnly :$left, TrueOnly :$right, TrueOnly :$center, TrueOnly :$autojustify,
       TrueOnly :$add,
       TrueOnly :$autofreq,
       :$incr,
       :$start, :$end,
       :@tics where Array[AnyTicsTic] | Array[],
       :$format, :$font-name, :$font-size, Bool :$enhanced,
       TrueOnly :$numeric, TrueOnly :$timedate, TrueOnly :$geographic,
       TrueOnly :$rangelimited,
       :$textcolor, :&writer? = -> $msg { self.command: $msg }
)

```

Controls the major (labeled) tics on the y2 axis.

### cbtics

Defined as:

```
method cbtics(
       TrueOnly :$axis, TrueOnly :$border, Bool :$mirror,
       TrueOnly :$in, TrueOnly :$out, TrueOnly :$scale-default, :$scale-major, :$scale-minor, AnyTicsRotate :$rotate, AnyTicsOffset :$offset,
       TrueOnly :$left, TrueOnly :$right, TrueOnly :$center, TrueOnly :$autojustify,
       TrueOnly :$add,
       TrueOnly :$autofreq,
       :$incr,
       :$start, :$end,
       :@tics where Array[AnyTicsTic] | Array[],
       :$format, :$font-name, :$font-size, Bool :$enhanced,
       TrueOnly :$numeric, TrueOnly :$timedate, TrueOnly :$geographic,
       TrueOnly :$rangelimited,
       :$textcolor, :&writer? = -> $msg { self.command: $msg }
)

```

Controls the major (labeled) tics on the color box axis.

### legend

Defined as:

```
method legend(
       TrueOnly :$on, TrueOnly :$off, TrueOnly :$default, TrueOnly :$inside, TrueOnly :$outside, TrueOnly :$lmargin, TrueOnly :$rmargin, TrueOnly :$tmargin, TrueOnly :$bmargin,
       :$at,
       TrueOnly :$left, TrueOnly :$right, TrueOnly :$center, TrueOnly :$top, TrueOnly :$bottom,
       TrueOnly :$vertical, TrueOnly :$horizontal, TrueOnly :$Left, TrueOnly :$Right,
       Bool :$opaque, Bool :$reverse, Bool :$invert,
       :$samplen, :$spacing, :$width, :$height,
       TrueOnly :$autotitle, TrueOnly :$columnheader, :$title, :$font-name, :$font-size, :$textcolor,
       Bool :$box, :$linestyle, :$linetype, :$linewidth,
       LegendMax :$maxcols, LegendMax :$maxrows, :&writer? = -> $msg { self.command: $msg }
)

```

Enables a key (or legend) containing a title and a sample (line, point, box) for each plot in the graph.

### border

Defined as:

```
method border(
       :$integer, TrueOnly :$front, TrueOnly :$back, TrueOnly :$behind,
       :lw(:$linewidth), :ls(:$linestyle), :lt(:$linetype), :&writer? = -> $msg { self.command: $msg }
)

```

Controls the display of the graph borders for the plot and splot commands.

### grid

Defined as:

```
method grid(
       Bool :$xtics, TrueOnly :$mxtics, Bool :$ytics, TrueOnly :$mytics, Bool :$ztics, TrueOnly :$mztics,
       Bool :$x2tics, TrueOnly :$mx2tics, Bool :$y2tics, TrueOnly :$my2tics, Bool :$cbtics, TrueOnly :$mcbtics,
       :$polar, TrueOnly :$layerdefault, TrueOnly :$front, TrueOnly :$back,
       :ls(:@linestyle), :lt(:@linetype), :lw(:@linewidth), :&writer? = -> $msg { self.command: $msg }
)

```

Allows grid lines to be drawn on the plot.

### timestamp

Defined as:

```
method timestamp(
        Str :$format, TrueOnly :$top, TrueOnly :$bottom, Bool :$rotate,
        :$offset, :$font-name, :$font-size, :$textcolor, :&writer? = -> $msg { self.command: $msg }
)

```

Places the time and date of the plot in the left margin.

### rectangle

Defined as:

```
multi method rectangle(
      :$index!, :$from, :$to,
      TrueOnly :$front, TrueOnly :$back, TrueOnly :$behind, Bool :$clip, :$fillcolor, :$fillstyle,
      TrueOnly :$default, :$linewidth, :$dashtype, :&writer? = -> $msg { self.command: $msg }
)

multi method rectangle(
      :$index, :$from, :$rto,
      TrueOnly :$front, TrueOnly :$back, TrueOnly :$behind, Bool :$clip, :$fillcolor, :$fillstyle,
      TrueOnly :$default, :$linewidth, :$dashtype, :&writer? = -> $msg { self.command: $msg }
)

```

Defines a single rectangle which will appear in all subsequent 2D plot.

### ellipse

Defined as:

```
method ellipse(
       :$index, :center(:$at), :$w!, :$h!,
       TrueOnly :$front, TrueOnly :$back, TrueOnly :$behind, Bool :$clip, :$fillcolor, :$fillstyle,
       TrueOnly :$default, :$linewidth, :$dashtype, :&writer? = -> $msg { self.command: $msg }
)

```

Defines a single ellipse which will appear in all subsequent 2D plot.

### circle

Defined as:

```
method circle(
       :$index, :center(:$at), :$radius!,
       TrueOnly :$front, TrueOnly :$back, TrueOnly :$behind, Bool :$clip, :$fillcolor, :$fillstyle,
       TrueOnly :$default, :$linewidth, :$dashtype, :&writer? = -> $msg { self.command: $msg }
)

```

Defines a single circle which will appear in all subsequent 2D plot.

### polygon

Defined as:

```
method polygon(
       :$index, :$from, :@to,
       TrueOnly :$front, TrueOnly :$back, TrueOnly :$behind, Bool :$clip, :$fillcolor, :$fillstyle,
       TrueOnly :$default, :$linewidth, :$dashtype, :&writer? = -> $msg { self.command: $msg }
)

```

Defines a single polygon which will appear in all subsequent 2D plot.

### title

Defined as:

```
method title(
       Str :$text, :$offset, :$font-name, :$font-size, :tc(:$textcolor), :$colorspec, Bool :$enhanced,
       :&writer? = -> $msg { self.command: $msg }
)

```

Produces a plot title that is centered at the top of the plot.

### arrow

Defined as:

```
multi method arrow(
      :$tag, :$from, :$to, Bool :$head, TrueOnly :$backhead, TrueOnly :$heads,
      :$head-length, :$head-angle, :$back-angle,
      Bool :$filled, TrueOnly :$empty, TrueOnly :$border,
      TrueOnly :$front, TrueOnly :$back,
      :ls(:$linestyle), :lt(:$linetype), :lw(:$linewidth), :lc(:$linecolor), :dt(:$dashtype), :&writer? = -> $msg { self.command: $msg }
)

```

Places an arrow on a plot.

### multiplot

Defined as:

```
multi method arrow(
      :$tag, :$from, :$rto, Bool :$head, TrueOnly :$backhead, TrueOnly :$heads,
      :$head-length, :$head-angle, :$back-angle,
      Bool :$filled, TrueOnly :$empty, TrueOnly :$border,
      TrueOnly :$front, TrueOnly :$back,
      :ls(:$linestyle), :lt(:$linetype), :lw(:$linewidth), :lc(:$linecolor), :dt(:$dashtype), :&writer? = -> $msg { self.command: $msg }
)

```

Places gnuplot in the multiplot mode, in which several plots are placed next to each other on the same page or screen window.

### command

Defined as:

```
method command(Str $command)

```

Runs a given `$command`. If there are no appropriate interfaces, this method will be a good alternative.

# EXAMPLES

## 3D surface from a grid (matrix) of Z values

### SOURCE

```
use Chart::Gnuplot;

my $gnu = Chart::Gnuplot.new(:terminal("png"), :filename("surface.dem.00.png"));
$gnu.title(:text("3D surface from a grid (matrix) of Z values"));
$gnu.xrange(:min(-0.5), :max(4.5));
$gnu.yrange(:min(-0.5), :max(4.5));
$gnu.grid;
$gnu.command("set hidden3d");

my @grid = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
5 4 3 1 0
2 2 0 0 1
0 0 0 1 0
0 0 0 2 3
0 1 2 4 3
EOF

$gnu.splot(:vertices(@grid), :style("lines"), :title(False), :matrix);
$gnu.dispose;

```

### OUTPUT

![3D surface from a grid (matrix) of Z values](surface.dem.00.png)

## sin(x)

### SOURCE

```
use Chart::Gnuplot;

my $gnu = Chart::Gnuplot.new(:terminal("png"), :filename("sinx.png"));
$gnu.title(:text("sin(x) curve"));
$gnu.plot(:function('sin(x)'));
$gnu.dispose;

```

### OUTPUT

![sin(x)](sinx.png)

## Recall-Precision Curve

### SOURCE

```
use v6;
use Chart::Gnuplot;

my $gnu = Chart::Gnuplot.new(:terminal("png"), :filename("recprec.png"));
$gnu.title(:text("Recall-Precision Curve"));
$gnu.ylabel(:label("Precision"));
$gnu.xlabel(:label("Recall"));
$gnu.xrange(:min(0.0), :max(1.0));
$gnu.yrange(:min(0.0), :max(1.0));

my @methodA = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
0.0 1.0
0.1 0.95
0.2 0.9
0.3 0.85
0.4 0.82
0.5 0.6
0.6 0.55
0.7 0.51
0.8 0.4
0.9 0.38
1.0 0.35
EOF

my @methodB = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
0.0 1.0
0.1 0.95
0.2 0.8
0.3 0.5
0.4 0.4
0.5 0.3
0.6 0.2
0.7 0.1
0.8 0.08
0.9 0.05
1.0 0.05
EOF

my %methodA = %(:vertices(@methodA), :style("linespoints"), :title("proposed"), :lc(qw/rgb "green"/), :pt(10));
my %methodB = %(:vertices(@methodB), :style("linespoints"), :title("baseline"), :lc(qw/rgb "red"/), :pt(13));

$gnu.plot(|%methodA);
$gnu.plot(|%methodB);
$gnu.dispose;

```

### OUTPUT

![recall precision curve](recprec.png)

# AUTHOR

titsuki [titsuki@cpan.org](mailto:titsuki@cpan.org)

# COPYRIGHT AND LICENSE

Copyright 2017 titsuki

This library is free software; you can redistribute it and/or modify it under the GNU General Public License version 3.0.


## dist_cpan-CTILMES-Trait-Enum.md
# NAME

Trait::Enum - Raku 'is enum' trait for enumerated types in CStruct classes

# SYNOPSIS

```
use Trait::Enum;

enum FooType <A B C>;

class Foo is repr('CStruct') {
    has int32 $.enum-foo-type is enum(FooType);
    has int32 $.enum-foo-writeable is rw is enum(FooType);
}

my $foo = Foo.new(enum-foo-type => 2, enum-foo-writeable => 1);

say $foo.foo-type;             # C        -- Returns enumeration value
say ~$foo.foo-type;            # 'C'      -- which stringifies
say +$foo.foo-type;            # 2        -- and numifies

say $foo.foo-writeable;        # B
say +$foo.foo-writeable;       # 1

$foo.foo-writeable(A);         # Can write a enumeration value
$foo.foo-writeable(1);         # Or an Int
$foo.foo-writeable('C');       # Or a Str

$foo.foo-writeable(17);        # Ok to write a bad integer
say $foo.foo-writeable;        # FooType, undefined enumeration

$foo.foo-writeable('bad');     # Bad string throws exception

```

# DESCRIPTION

This is a temporary, experimental trait mainly because Raku Native `CStruct` classes don't currently allow enumerated types in them. Once they do, this module will be retired. In the mean time, it makes it very easy to map enumerations into CStruct structures making them more friendly to interact with from Raku.

The trait can only be added on attributes named with the prefix 'enum-'. It adds an additional accessor method without that prefix. (You can still use the 'enum-' accessor methods with the original type.) The new accessor method returns the specified enum.

Naturally this trait must be used only with integer fields (int32, int16, etc.)

If the attribute is also 'rw', three additional multi methods for writing to to the attribute either an Int, a Str, or an actual enumerated value.

# LICENSE

This work is subject to the Artistic License 2.0.


## dist_cpan-HANENKAMP-Template-Anti.md
# NAME

Template::Anti - The anti-template templating tool

# SYNOPSIS

```
use Template::Anti;

class MyApp::View {
    has $.token; # custom attributes, if you want them

    method hello($dom, :$title, :$welcome-message) is anti-template(:source<welcome.html>) {
        $dom('title', :one).content($title);
        $dom('.welcome-message', :one).content($welcome-message);
        $dom('input#api_token', :one).val($!token);
    }

    # Or put the logic into people.html:
    # <script type="application/anti+perl6">
    #   $dom('input#api_token', :one).val($!token);
    #   $dom('title, h1')».content(.<title>);
    #   $dom('h1')».attr(title => .<motto>);
    #   $dom('ul.people li:not(:first-child)')».remove;
    #   $dom('ul.people li:first-child', :one)\
    #       .duplicate(.<sith-lords>, -> $item, $_ {
    #           $item('a', :one).content(.<name>).attr(href => .<url>);
    #       });
    # </script>
    method sith($dom, $_) is anti-template(:source<people.html>) {
        ... # yada signals embedded logic
    }
}

# The source files are just plain old HTML. Nothing special about them.

# Construct a library of templates
my $ta = Template::Anti::Library.new(
    path  => </var/myapp/template-root/ /var/myapp/other-template-root/>,
    views => {
        main => MyApp::View.new(:token<secret>),
    },
);

# Use .process() to render the templates with input
say $ta.process('main.hello', :title<Hello World>, :welcome-message<Welcome!>);
say $ta.process('main.site', %sith-lords);

```

# DESCRIPTION

It is a generally accepted principle that you should avoid mixing code with presentation. Yet, whenever a software engineer needs to render some custom HTML or text or something, the first tool she pulls out of her toolbelt is a templating engine, which does that very thing. Rather than building a file that is either some nice programming language like Perl 6 or a decent document language like HTML5, she ends up with some evil hybrid that:

* Confuses tools made to read either of those languages,
* Adds training overhead and burdensome syntax for your front-end developers to work around,
* Generally uglifies your code making your templates harder to read as they mix two or three language syntaxes together inline.

This "templating" engine allows you to put an end to that.

This module, Template::Anti, is the anti-templating engine. This tool splits your presentation from your code in a way that is familiar to many front-end developers, using a select-and-modify methodology similar to jQuery.

It borrows a few ideas from tools like [Template::Pure](https://metacpan.org/pod/HTML::Zoom), [Template::Semantic](https://metacpan.org/pod/Template::Semantic), and [pure.js](https://beebole.com/pure/).

# Template Source

To build a template you need two components:

* You need some HTML or XML source to work with.
* You need a block of code to execute against the parsed representation of that source.

From there, Template::Anti provides two different ways to process your templates, inline (a.k.a. embedded) and out-of-line. Let's consider the latter first.

## Out-of-Line Processing

This is the "pure" use-case that completely separates your template from your view processor, which should maximize reuse for most applications. To do this, you create an HTML original and then a method to apply a set of rules and modifications to it, like this:

```
class MyTemplate {
    method index($dom, :$title) is anti-template(:source<index.html>) {
        $dom('title')».content($title);
    }
}

```

The `is anti-template` trait associates a source file name with your method. When it comes time to process the template, this will be found within the search paths setup in </Template::Anti::Library>. The trait takes two optional named parameters:

* The `source` parameter will name the original file to associate with this processing method.
* The `format` parameter names the format to use when parsing the original. It defaults to `HTML` but may be set to `XML` instead.

The first positional argument to the method will always be the DOM object parsed from the original source file. The remaining parameters are whatever you want to pass to your views.

## Inline Processing

At times, it may be convenient to keep your processing code within the original file. In this case, your original file will include zero or more `<script></script>` blocks with the type attribute set to "application/anti+perl6". For example, here is a simple template you might have in your assets directory:

```
<html>
    <head>
        <title>Hello</title>
        <script type="application/anti+perl6" data-dom="$tmpl" data-stash="$data">
        $tmpl('title', h1').text($data<title>);
        </script>
    </head>
    <body>
        <h1>Hello</h1>
    </body>
</html>

```

The `type="application/anti+perl6"` attirbute is required. The `data-dom` and `data-stash` attributes are optional. These attributes the names of the template variables the engine will provide to the block.

The `data-dom` names the variable to use for the DOM representation within the script-tag. (The DOM will be provided without these script-tags present.) The default `data-dom` name is `"$dom"`.

The `data-stash` attribute names the variable to use for the remaining captured arguments. The default `data-stash` name is `"$_"`. It is up to the code within the script-tag to handle any further argument handling.

This works whether the template is HTML or XML. However, when templating with XML, it is also recommended that you wrap your code in a `<![CDATA[ ]]>` section to avoid problems with greater than signs (">"), less than signs ("<"), and ampersands in your code confusing the parser.

Finally, the processing method for this template looks like the following:

```
class MyTemplate {
    method index(|) is anti-template(:source<index.html>) {
        ...
    }
}

```

The yada (...) signals that this the method logic will be filled in by scripts embedded within the original. The capture bar (|) is shown here because the method itself is just a placeholder and won't actually be called or used. The arguments you set here do not matter at all, so it is recommended you leave them blank in whichever way you prefer.

# Template::Anti::Library

This class provides tools for locating original source files for parsing and for grouping your processing methods together. You do not have to use it. If you only need a single template or want to provide your own mechanism for locating and reading the files and calling the templates, see [/One-off Templates](/One-off Templates) for details.

## method path

```
method path() returns Array:D

```

This is the accessor for the paths set when Template::Anti::Library is constructed.

```
my $ta = Template::Anti::Library.new(
    path => </var/www /var/www2>,
    ...
);

```

These paths name the template sources that are searched when locating an original source file. These may given as strings, which will be coerced into IO::Path objects, as IO::Path objects, or as Template::Anti::ResourcesPath objects. The last option allows you to ship your templates as part of the distribution's resource files:

```
my $ta = Template::Anti::Library.new(
    path => Template::Anti::ResourcesPath.new(
        resources => %?RESOURCES,
        prefix    => 'path/to/templates',
    ),
    ...
);

```

These might be other kinds of search paths as well. See `path-searcher` for even more flexibility with what is provided to `path`.

## method views

```
method views() returns Hash:D

```

This is the accessor for the views set when Template::Anti::Library is constructed.

```
my $ta = Template::Anti::Library.new(
    views => {
        user => MyApp::View::User.new,
        page => MyApp::View::Page.new,
        book => MyApp::View::Book.new,
    },
    ...
);

```

This is a map of names to objects that each should contain one or more methods that have been tagged with the `is anti-template` trait. The names are used by the [/method process](/method process) as part of the name used to look up the template to process.

## method path-searcher

```
method path-searcher() returns Array:D

```

Thisi s the accessor for the path searcher plugins configured during construction. By default this includes two plugins, in this order:

* `Template::Anti::Library::Resources` If a `path` is given a `Template::Anti::ResourcesPath` object as a search path, the named resources object will be searched for source files. This plugin uses the `resources` provided to that object as the hash to search. It prefixes the given `prefix`, if any is provided, to find the source files in the distribution's `%?RESOURCES`.
* `Template::Anti::Library::IO` If a `path` is given as a <Str> or as a IO::Path object, this will assume that value is a directory to search for source files.

In addition to these, you may provide your own path searcher plugins. These plugins must implement the `Template::Anti::Library::PathSearcher` role, which requires one method to be implemented:

```
method search($path, Str $template --> IO::Handle) { ... }

```

This method should return `Nil` when the named `$template` is not found in this search path or a defined IO::Handle-like object if it is found. At this time, all that's required is that the defined object provide the `.slurp()` method, but future releases may require (or benefit from) additional functionality.

## method process

```
method process(Str $template, |c) returns Str:D

```

This is the workhorse of the system. If the named template has never been processed before, the source template will be located, read, and parsed according to the format for that template. This setup happens once and the result is then cached. It will then process the arguments passed (any arguments after the template name are passed as is through to the processing method).

The `$template` name itself should be composed of two names separated by a period ("."). The first name is name given to the [/method views](/method views) parameter. The second is the name of the processing method to call on that object.

# Template::Anti::ResourcesPath

## method resources

```
method resources(--> Associative:D)

```

When used to setup a search path in `Template::Anti::Library`, this should be set to `%?RESOURCES` within the current distribution.

## method prefix

```
method prefix(--> Str)

```

When used to setup a search path in `Template::Anti::Library`, this is the prefix to add to every key being looked up in `resources`. This will be path-like, so a prefix of "stuff" and a template named "things.html" will result in a key lookup like "stuff/things.html".

# Template::Anti::Library::PathSearcher

This is a role that must be implemented by any custom path searcher plugin. It is implemented by `Template::Anti::Library::Resources` and `Template::Anti::Lirary::IO`.

## method search

```
method search($path, Str $template --> IO::Handle)

```

This method must be implemented by all plugin searcher classes. It will return `Nil` if no template named `$template` can be found at the given `$path` and also when the plugin does not know how to intepret whatever kind of object `$path` is.

# Template::Anti::Library::Resources

This is a path searcher that is able to turn `Template::Anti::ResourcesPath` path objects into source files.

# Template::Anti::Library::IO

This is a path searcher that is able to turn <Str> and IO::Path path objects into source files.

# Exported Routines

## trait is anti-template

```
sub trait_mod:<is> (Routine $r, :$anti-template)

```

This marks a method as being a Template::Anti processing method. It takes two named arguments.

```
method tmpl($dom, *%stash) is anti-template(
    :source<file.html>,
    :format(HTML),
) { ... }

```

The `:source` is the name of the file to load. The location of the file is relatives to the paths set on the `path` attribute on </Template::Anti::Library>.

The `:format` is the format to use, usually `HTML` or `XML` unless you have defined your own custom formats.

A method declared with this trait that is a yada-method (i.e., it has no code in the block, just a yada (...), will cause Template::Anti to assume that the code is embedded within the original source file named in `:source`.

## sub anti-template

```
use Template::Anti :one-off;
sub anti-template(&process?, Str:D :$source!, Template::Anti::Format :$format = DOM) returns Routine:D

```

This is exported in the `:one-off` export group. This routine builds a template routine and returns it. The returned routine completely encapsulates the processing of the template.

See [/One-off Templates](/One-off Templates) for a full example of this routine in action.

The `&process` is optional. When given, it names the routine to call to transform a template source and stash into a final version of the template source. If not given, it is assumed that any processing will be embedded within the template. When given, it should expect at least one positional argument, which will be the DOM object parsed from the original in `$source`. Any remaining arguments are whatever will be passed to the returned routine.

```
sub ($dom, |c) { ... }

```

The return value of this routine is ignored. It may modify the `$dom` object in place. The type of that `$dom` object will be a subclass of DOM::Tiny when `$format` is set to `HTML` and `XML`.

The `$source` is required and contains the complete contents of the original file source. For `HTML` formats, this would be a regular HTML file. For `XML` formats, it would be a regular XML file.

The `$format` tells the `anti-template` routine which format the file is in and how to parse and process it. Template::Anti provides built-in formats, `Template::Anti::Format::DOM`, `Template::Anti::Format::HTML`, and `Template::Anti::Format::XML`, which are exported by default as `DOM`, `HTML`, and `XML`, respectively. `XML` and `HTML` are both subclasses of `DOM`. Each use a slightly extended DOM::Tiny to parse and process the file. Custom formats can also be crafted. See [/Advanced Formats](/Advanced Formats).

The format also determines how to extract embedded templates. In the case of `DOM`, `HTML`, `XML`, the embedding is handled via `<script>` tags that have the type set to "application/anti+perl6". These actually support the use of multiple `<script>` tags, which are process in order they appear in the file, each getting it's own `data-dom` and `data-stash` settings (see [/Inline Processing](/Inline Processing)).

The returned routine will work something like this:

```
sub (|c) returns Str:D { ... }

```

Here the `|c` capture will be passed through to the `&process` routine. Here are a few quick examples:

```
sub process1($dom) { ... }
my &process1-template = anti-template(&process1, ...);
say process1-template();

sub process2($dom, $user, :$title, :$name) { ... }
my &process2-template = anti-template(&process2, ...);
say process2-template(MyUser.new(0), :title<Hello>, :name<Bob>);

sub process3($dom, %stash) { ... }
my &process3-template = anti-template(&process3, ...);
say process3-template(%myapp-stash);

```

The arguments are passed through in just that fashion.

Once the `&process` passed to `anti-template` has been called, the template object (`$dom` in the signature above), will be serialized by calling the `Str` method on it. That stringified version of the value is returned.

# DOM::Tiny Customization

When the built-in formats, `DOM`, `HTML`, and `XML`, are used Template::Anti uses a slightly customized subclass of DOM::Tiny that provide a couple additional features that are useful when processing the original source file. Some or all of these might be rolled up into DOM::Tiny in the future, but they are here for now.

(It should be noted that where the signatures here show DOM::Tiny, this is really returning the slightly extended subclass that Template::Anti provies. The name of that subclass is not documented because it is expected to change in the future.)

## method postcircumfix:<( )>

```
multi method postcircumfix:<( )> ($selector) returns Seq:D
multi method postcircumfix:<( )> ($selector, Bool :$one) returns DOM::Tiny:D

```

This allows for a sometimes shortened notation when using DOM::Tiny. Basically, the following are equivalent:

```
# Long notation
@ps = $dom.find('p');
$p  = $dom.at('p');

# Short notation
@ps = $dom('p');
$p  = $dom('p', :one);

```

Use whichever you prefer.

## method duplicate

```
method duplicate(@items, &dup) returns DOM::Tiny:D

```

This performs a complicated operation that is useful when you want to loop over several stash values and duplicate some part of your DOM using variants. Here's a simple example to illustrate:

```
$dom.at('li').duplicate([ 1, 2, 3 ], -> $li, $number {
    $li.content($number);
});

```

If our source started out as:

```
<ul>
    <li>demo</li>
</ul>

```

It would now rea:

```
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
</ul>

```

# One-Off Templates

If you just need a quick template and don't need to worry about building a complete library of methods, there is also a mechanism for creating one-off template routines. This requires using the `anti-template` routine, which is exported when the `:one-off` flag is passed during import.

```
use Template::Anti :one-off;

my $source = q:to/END_OF_SOURCE/;
<html><head><title>Hello World</title></head>
<body>
    <h1>Hello World</h1>
    <ul class="people">
        <li><a href="/person1'>Alice</a></li>
        <li><a href="/person2'>Bob</a></li>
        <li><a href="/person3'>Charlie</a></li>
    </ul>
</body></html>
END_OF_SOURCE

my &hello = anti-template :$source, -> $dom, $_ {
    $dom('title, h1')».content(.<title>);
    $dom('h1')».attr(title => .<motto>);
    $dom('ul.people li:not(:first-child)')».remove;
    $dom('ul.people li:first-child', :one)\
        .duplicate(.<sith-lords>, -> $item, $_ {
            $item('a', :one).content(.<name>).attr(href => .<url>);
        });
}

# Render the output:
print hello(
    title      => 'Sith Lords',
    motto      => 'The Force shall free me.',
    sith-lords => [
        { name => 'Vader',   url => 'http://example.com/vader' },
        { name => 'Sidious', url => 'http://example.com/sidious' },
    ],
);

# Or if you must mix your code and presentation, you can embed the rules
# within a <script/> tag in the source, which is still better than mixing it
# all over your HTML:
my $emb-source = q:to/END_OF_SOURCE/;
<html><head><title>Hello World</title></head>
<body>
    <h1>Hello World</h1>
    <ul class="people">
        <li><a href="/person1">Alice</a></li>
        <li><a href="/person2">Bob</a></li>
        <li><a href="/person3">Charlie</a></li>
    </ul>
    <script type="application/anti+perl6" data-dom="$dom">
        $dom('title, h1')».content(.<title>);
        $dom('h1')».attr(title => .<motto>);
        $dom('ul.people li:not(:first-child)')».remove;
        $dom('ul.people li:first-child', :one)\
            .duplicate(.<sith-lords>, -> $item, $_ {
                $item('a', :one).content(.<name>).attr(href => .<url>);
            });
    </script>
</body></html>
END_OF_SOURCE

my &hello-again = anti-template :source($emb-source), :html, :embedded;
print hello-again(%vars);

```

# Advanced Formats

While this library has been built using DOM::Tiny to implement XML and HTML parsing and rendering of template sources, it is possible to extend Template::Anti to support parsing sources in any other format. To do this, you need to define a custom class that extends Template::Anti::Format in your code. For example, here is one built with the help of a second anonymous classes that will work with plain text files that contain specially formatted blanks.

```
class BlankText is Template::Anti::Format {
    method parse($source) {
        class {
            has $.source is rw;

            method set($blank, $value) {
                $!source ~~ s:g/ "_$blank_" /$value/;
                Mu
            }

            method Str { $.source }
        }.new(:$source);
    }

    method prepare-original($master) {
        $master.clone;
    }

    method embedded-source($master) {
        my $code;
        ($master.source, $code) = $master.source.split("\n__CODE__\n", 2);

        use MONKEY-SEE-NO-EVAL;
        my $sub = $code.EVAL;

        $sub;
    }

    method render($final) { $final.source }
}

```

The `parse` method is only called once, when the template is initially built. This is called before the template is ever processed. This method should take the given string as the template to parse and parse it. Then, the `prepare-original` method will be called just before processing each call to the template. This allows the original to be parsed once and cached. Finally, the `render` method will be called to retrieve the final serialized version of the now modified original.

This also adds support for embedding the code part of the template in the source following a `__CODE__` annotation. Here's a couple examples using this custom object. The `embedded-source` method will be called witha reference to the master returned by `parse` and the value cached will include any modifications that the `embedded-source` method makes to the original document.

In `welcome.txt`, we could have this:

```
Subject: Welcome _name_ to the Dark Side

_name_

Welcome to the Dark Side. Enclosed you will find instructions on how
to reach the Sith planet to begin your training.

Love,
_dark-lord_

```

And in `welcome-embedded.html`, we could have this:

```
Subject: Welcome _name_ to the Dark Side

_name_

Welcome to the Dark Side. Enclosed you will find instructions on how
to reach the Sith planet to begin your training.

Love,
_dark-lord_

__CODE__
sub ($email, *%data) {
    $email.set($_, %data{ $_ }) for <name dark-lord>;
}

```

And in our code, we can write this:

```
use Template::Anti;

class MyEmails {
    method hello($email, *%data) is anti-template(:source<welcome.txt>, :format(BlankText)) {
        $email.set($_, %data{ $_ }) for <name dark-lord>;
    }

    method hello-embedded($email, %adata) is anti-template(:source<welcome-embedded.txt>, :format(BlankText)) {
        ...
    }
}

my $ta = Template::Anti::Library.new(
    path  => </var/myapp/root>,
    views => { :email(MyEmails.new) },
);

say $ta.process('email.hello', :name<Starkiller>, :dark-lord<Darth Vader>);
say $ta.process('email.hello-embedded', :name<Starkiller>, :dark-lord<Darth Vader>);

```

This way, you can get code separated from your templates in any format you like.

If your format class does not have an `embedded-source` method defined, attempting to us the embedded form of `anti-template` will result in an exception.

Finally, the format class must supply a `render` method to serialize the object to string.


## dist_cpan-HANENKAMP-HTTP-Request-Supply.md
# NAME

HTTP::Request::Supply - A modern HTTP/1.x request parser

# SYNOPSIS

```
use HTTP::Request::Supply;

react {
    whenever IO::Socket::Async.listen('localhost', 8080) -> $conn {
        my $envs = HTTP::Request::Supply.parse-http($conn);
        whenever $envs -> %env {
            my $res = await app(%env);
            handle-response($conn, $res);

            QUIT {
                when X::HTTP::Request::Supply::UnsupportedProtocol {
                    $conn.print("505 HTTP Version Not Supported HTTP/1.1\r\n");
                    $conn.print("Content-Length: 26\r\n");
                    $conn.print("Content-Type: text/plain\r\n\r\n");
                    $conn.print("HTTP Version Not Supported\r\n");

                    .note;
                    $conn.close;
                }

                when X::HTTP::Request::Supply::BadRequest {
                    $conn.print("400 Bad Request HTTP/1.1\r\n");
                    $conn.print("Content-Length: " ~ .message.encode.bytes ~ \r\n");
                    $conn.print("Content-Type: text/plain\r\n\r\n");
                    $conn.print(.message);
                    $conn.print("\r\n");

                    .note;
                    $conn.close;
                }

                default {
                    $conn.print("500 Internal Server Error HTTP/1.1\r\n");
                    $conn.print("Content-Length: 22\r\n");
                    $conn.print("Content-Type: text/plain\r\n\r\n");
                    $conn.print("Internal Server Error\r\n");

                    .note;
                    $conn.close;
                }
            }
        }
    }
}

```

# DESCRIPTION

**EXPERIMENTAL:** The API for this module is experimental and may change.

This class provides a <Supply> that is able to parse a series of request frames from an HTTP/1.x connection. Given a <Supply>, it consumes binary input from it. It detects the request frame or frames within the stream and passes them back to any taps on the supply asynchronously as they arrive.

This Supply emits partial <P6WAPI> compatible environments for use by the caller. If a problem is detected in the stream, it will quit with an exception.

# METHODS

## sub parse-http

```
sub parse-http(Supply:D() :$conn, :&promise-maker) returns Supply:D

```

The given <Supply>, `$conn` must emit a stream of bytes. Any other data will result in undefined behavior. The parser assumes that only binary bytes will be sent and makes no particular effort to verify that assumption.

The returned supply will react whenever data is emitted on the input supply. The incoming bytes are collated into HTTP frames, which are parsed to determine the contents of the headers. Headers are encoded into strings via ISO-8859-1 (as per [RFC7230 §3.2.4](https://tools.ietf.org/html/rfc7230#section-3.2.4)).

Once the headers for a given frame have been read, a partial <P6WAPI> compatible environment is generated from the headers and emitted to the returned Supply. The environment will be filled as follows:

# over

* If a `Content-Length` header is present, it will be set in `CONTENT_LENGTH`.
* If a `Content-Type` header is present, it will be set in `CONTENT_TYPE`.
* Other headers will be set in `HTTP_*` where the header name is converted to uppercase and dashes are replaced with underscores.
* The `REQUEST_METHOD` will be set to the method given in the request line.
* The `SERVER_PROTOCOL` will be set to the protocol given in the request line. (As of this writing, this will always be either HTTP/1.0 or HTTP/1.1 as these are the only protocol versions this module currently supports.)
* The `REQUEST_URI` will be set to the URI given in the request line.
* The `p6w.input` variable will be set to a sane <Supply> that emits chunks of the body as bytes as they arrive. No attempt is made to decode these bytes.

# back

No other keys will be set. A complete P6WAPI environment must contain many other keys.

# DIAGNOSTICS

The following exceptions are thrown by this class while processing input, which will trigger the quit handlers on the Supply.

## X::HTTP::Request::Supply::UnsupportedProtocol

This exception will be thrown if the stream does not seem to be HTTP or if the requested HTTP version is not 1.0 or 1.1.

## X::HTTP::Request::Supply::BadRequest

This exception will be thrown if the HTTP request is incorrectly framed. This may happen when the request does not specify its content length using a `Content-Length` header or chunked `Transfer-Encoding`.

# CAVEATS

This code aims at providing a minimal implementation that is just enough to decode the HTTP frames and provide the information about the raw requests to the tapping code. It is not safe to assume that anything provided has been validated or processed.

HTTP is complicated and hard. This implementation is not yet complete and not battle tested yet. Please report bugs to github and patches are welcome. Even once this code matures, it will never receive the TLC that a full-blown general web server is going to get as regards hardening and maturity on the Internet. As such, the author always recommends using this code behind an existing, well-known, and well-maintained web server in production. This is only ever intended as a "bare metal" application server interface.

This interface is built with the intention of making it easier to build HTTP/1.0 and HTTP/1.1 parsers for use with <P6WAPI>. As of this writing, that specification is only a proposed draft, so the output of this module is experimental and will change as that specification changes.

Finally, this module only takes responsibility for parsing the incoming HTTP frames. It does not manage the connection and it provides no tools for sending responses back to the user agent.

# AUTHOR

Sterling Hanenkamp `<hanenkamp@cpan.org>`

# COPYRIGHT & LICENSE

Copyright 2016 Sterling Hanenkamp.

This software is licensed under the same terms as Perl 6.


## dist_github-grondilu-Chess.md
# Chess

Chess-related stuff in Raku

## SYNOPSIS

```
$ raku -MChess
> say startpos;
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
> say startpos * 'e4'; # position after 1.e4
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
> (startpos * 'd4').ascii;  # see further for kitty terminal
   +------------------------+
 8 | r  n  b  q  k  b  n  r |
 7 | p  p  p  p  p  p  p  p |
 6 | .  .  .  .  .  .  .  . |
 5 | .  .  .  .  .  .  .  . |
 4 | .  .  .  P  .  .  .  . |
 3 | .  .  .  .  .  .  .  . |
 2 | P  P  P  .  P  P  P  P |
 1 | R  N  B  Q  K  B  N  R |
   +------------------------+
> say legal-moves startpos;
[d3 d4 e3 e4 c3 c4 f3 f4 Nf3 Nh3 h3 h4 a3 a4 g3 g4 Na3 Nc3 b3 b4]

```

## Description

### PGN Grammar

```
use Chess::PGN;
say Chess::PGN.parse: "1. f3 e5 2. g4?? Qh4#";

```

### FEN Grammar

```
use Chess::FEN;
say Chess::FEN.parse('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');

```

See [the wikipedia article about FEN](http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation) for more information.

## General utilities

### Graphical display

In addition to the ASCII representation mentioned above,
there are two other possibilities to display a chess position:

* one is using unicode chess characters, along with escape code sequences to change the background and foreground colors of each square.
* the other is using [Kitty's graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/). This second solution is a bit slow
  at startup, it requires [ImageMagick](https://imagemagick.org/script/command-line-tools.php) to be installed on your system,
  and it's not very robust to things like terminal zoom or scrolling. It looks very good though, using the same piece set as the default one
  on lichess.

![showing the start position ascii, unicode and kitty](https://i.imgur.com/yX5FAUt.png)

### Polyglot books

WIP

## TODO

* implement rules of the game
* interface Stockfish
* make Board image internally, not relying on lichess
* opening and tactics trainer
* game database management
* translate [Chess.js](https://github.com/jhlywa/chess.js/tree/master)
* read and write [Polyglot books](https://www.chessprogramming.org/PolyGlot)
* make the board square as tall as the cursor by default
* clean-up and update README


## dist_github-MadcapJake-Test-Lab.md
# 🔬 Test::Lab

[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/MadcapJake/Test-Lab/Tests%20on%20source?style=flat-square)](https://github.com/MadcapJake/Test-Lab/actions/workflows/test.yml) [![Issues](https://img.shields.io/github/issues/MadcapJake/Test-Lab.svg)](https://github.com/MadcapJake/Test-Lab/issues) [![License](https://img.shields.io/github/license/MadcapJake/Test-Lab.svg)](https://github.com/MadcapJake/p6dx/blob/master/LICENSE)

Careful refactoring of critical paths. A port of Github's [Scientist](https://github.com/github/scientist) to Raku.

## How do I start a lab?

Use the lab sub to build a default experiment for you:

```
use Test::Lab;

class MyWidget {
  method is-allowed($user) {
    lab 'widget-permissions', -> $e {
      $e.use: { $!model.check-user($user).is-valid } # old way
      $e.try: { $user.can('read', $!model) } # new way
    }
  }
}

```

Use the `Test::Lab::Experiment` class to instantiate a default experiment:

```
use Test::Lab::Experiment;

class MyWidget {
  method allows($user) {
    my $experiment = Test::Lab::Experiment.new(:name<widget-permissions>);
    $experiment.use: { $!model.check-user($user).is-valid } # old way
    $experiment.try: { $user.can :$!model :read } # new way

    $experiment.run;
  }
}

```

Change the default Experiment class to publish your results:

```
class MyExperiment is Test::Lab::Experiment {
  method is-enabled { ... }
  method publish($result) { ... }
}
Test::Lab::<$experiment-class> = MyExperiment;

```

Now you can use `lab` as before and it will utilize your own experiment class. This is highly useful as `Test::Lab::Default` provides no publishing and thus no way to gain access to the results.


## dist_zef-melezhik-Sparrow6-Rakudo-Install.md
# Sparrow6::Rakudo::Install

Sparrow6 plugin to install various versions of Rakudo

# Install

`zef install Sparrow6::Rakudo::Install`

# Usage

Inside your Sparrow scenario:

```
user "test123";

zef "https://github.com/melezhik/sparrow6-rakudo-install.git";

module-run 'Rakudo::Install', %(
  user => 'test123',
  rakudo-version => '40b13322c503808235d9fec782d3767eb8edb899'
);

# Now you can use installed Rakudo and Zef

bash "raku --version", %(
  user => "test123"
)

bash "zef --version", %(
  user => "test123"
)

```

# Parameters

## user

User to install

## rakudo-version

Rakudo version, should full SHA, see <https://github.com/rakudo/rakudo/commits/>

## skip-install-dependencies

Don't install system dependencies (wget,zstd so on)

## skip-zef

Don't install zef

## patch-profile

Patch user's bash profile. Optional, default value is `True`

# See also

[Sparrow6 modules](https://github.com/melezhik/Sparrow6/blob/master/documentation/modules.md)

# Author

Alexey Melezhik


## dist_github-supernovus-Text-Table-List.md
# Text::Table::List

## Introduction

A library to build simple text-based tables for use on a command line
interface. We're using Unicode box drawing characters by default, so please
ensure your terminal supports them. If not, never fear, you can use the
Text::Table::List::ASCII varient which uses standard ASCII characters, or
define your own set of characters entirely.

## Usage

Currently we only support a very minimal table-like structure, here is one
example:

```
my $t1 = Text::Table::List.new(:length(40)).start;
$t1.label("A Test Table");
$t1.line;
$t1.field("Hello:", "World");
$t1.field("Goodbye:", "Universe");
$t1.line;
$t1.label("And now for some numbers.");
$t1.blank;
$t1.field("Pi:", pi.base(16));
$t1.field("The Answer:", 42);
$t1.field("Nonsense:", "31.34892");

```

The above would output something that looks like:

```

  ╔══════════════════════════════════════╗
  ║ A Test Table                         ║
  ╟──────────────────────────────────────╢
  ║ Hello:                         World ║
  ║ Goodbye:                    Universe ║
  ╟──────────────────────────────────────╢
  ║ And now for some numbers.            ║
  ║                                      ║
  ║ Pi:                         3.243F6A ║
  ║ The Answer:                       42 ║
  ║ Nonsense:                   31.34892 ║
  ╚══════════════════════════════════════╝

```

You can also pass multiple named paramters to the field() method and each
one will be used as a name/value pair.

For more, see the tests and examples, in the 't' and 'example' folders
respectively.

## Future

This module is pretty simple, and supports only a very small subset of
the functionality expected from a table. The most obvious is that it does
not support any form of real columns. It has separator lines, blank lines,
labels and fields (which consist of a name and a value.) That's it.

So, for a future project, I'd like to build another Text::Table::\* module
that allows you to build text-based tables with full column support.

It will be it's own project, as I want to keep this one as simple as possible.

## Author

Timothy Totten, supernovus on #perl6, <https://github.com/supernovus/>

## License

[Artistic License 2.0](http://www.perlfoundation.org/artistic_license_2_0)


## dist_cpan-ALOREN-Getopt-Advance.md
![Build
Status](https://travis-ci.org/araraloren/raku-getopt-advance.svg?branch=master)
![Windows Build
Status](https://ci.appveyor.com/api/projects/status/1aknogb99475ak53/branch/master?svg=true)

An advance command line parse tool replace Getopt::Kinoko

# Description

`Getopt::Advance` is a powerful command line option parsing module, it
suppot many style such as: `unix-style`、`gnu-style`、`bsd-style`.etc.
It support `Hash`、`Array` option compared to traditional command line
tools. In addition, it also support `radio`、`multi` group mechanism
which can manage option realtionship. And to handle non-option argument,
it provide `main`、`pos` and `cmd` feature.

# Usage

## Try it

### Normal version

```
use Getopt::Advance;

my OptionSet $os .= new();

$os.push(
    "h|help=b",
    "print help message.",
    callback => sub ($, $) {
        say "The h option is set by user";
    });

&getopt($os);
say "Exit!";

```

### With react

```
use Getopt::Advance;

my OptionSet $os .= new();

$os.push("h|help=b", "print help message.");

react {
    whenever $os.Supply("h") {
        say "The h option is set by user";
    }
    whenever &getopt($os) {
        say "Exit!";
        done;
    }
}

```

## Feature

The feature support by this module, more information please refer
documents.

* Option with type

  * Long and short option supported, such as `-o` and `--option`.
  * X-style option supported, such as `-option`.
  * Combing-style option supported, such as `-abc` is same as `-a`
    `-b` `-c`.
  * BSD-style supported, such as `abc` is set the boolean option
    `a`, `b` and `c`.
  * Multiple style provide option arguments, such as `-a=b`, `-a b`,
    `-ab` is mean set the value of option `a` to `b`.
  * Deactivate-style support, mean you can disable some option by
    using `-/o`.
  * Type supported, such as `Boolean`, `Integer`, `Array`, and
    `String`, i.e. will check the option argument provide by user.
* Non Option with index

  * Sub command supported, it can provide different feature to user,
    such as `script.p6 add …` and `script.p6 del …`.
  * Position argument base on index supported, such as
    `script.p6 <file>` will capture the first non-option argument
    provide by user.
  * Main function supported. Main function will call with all the
    non-option arguments.
* Option rule

  * With `radio` group, can only set one by user, or must set one by
    user.
  * With `multi` group, can limiting the options set at least one.
  * Must be set by user if optional of option is False.
* Callback of Option/Non Option

  * Can set the callback of Option/Non Option, it will be called
    when it set by user.
* Auto-generated help, version message

  * It can generate help and version message for you.
  * If `autohv` is set, it can automate print help or version
    message when corresponding option set by user.
* PreParser

  * With the parser, you can process some option first, and process
    other with another call.
* Interrupt the program

  * With sub such as `ga-want-helper`, you can interrupt the program
    and print help immediately.
* Default value of Option
* Load option from class/sub (not implement)
* Load from the configure file easily

  * Refer the example [make-cpan-pack](sample/make-cpan-pack.p6).
* Thing can Custom by user

  * Help generator.
  * Option Parser.
  * Style supported and the priority of them.
  * The order of `Option` value assignment and `Pos`, `Cmd` process.

## Document

[Getopt-Advance](doc/Getopt/Advance.adoc)

## Example

### App::snippet

[Run your c/c++ code.](https://github.com/araraloren/raku-app-snippet)

### App::FindSource

[Find your source file
easily!](https://github.com/araraloren/raku-app-findsource)

### xcp

A [script](sample/xcp.p6) display the copy progress.

### pdnf

[pdnf](sample/pdnf.p6) added some sort command to dnf(package manager of
some linux distribution).

### find-file

[find-file](sample/find-file.p6)

#### usage

**help**

```
$ ./find-file.p6
Usage:
./sample/find-file.p6 [directory] OPTIONs

-d               specify file type to directory

-v|--version     print program version.

--size=<integer> the minimum size limit of file.

-?               same as -h.

-h|--help        print this help.

-f               specify file type to normal file

-l               specify file type to symlink

```

**find**

```
$ ./find-file.p6 ../t '1\d.*t$'
../t/11-bsd-style.t
../t/10-x-style.t

```

# Installation

* install with zef

  ```
  zef install Getopt::Advance

  ```

# Lincese

The MIT License (MIT).

# TODO

* Update documents
* Update subs feature


## dist_zef-raku-community-modules-HTTP-Easy.md
[![Actions Status](https://github.com/raku-community-modules/HTTP-Easy/actions/workflows/test.yml/badge.svg)](https://github.com/raku-community-modules/HTTP-Easy/actions)

# NAME

HTTP::Easy - HTTP servers made easy, including PSGI

# SYNOPSIS

```
use HTTP::Easy;

```

# DESCRIPTION

Raku libraries to make HTTP servers easily.

This was inspired by `HTTP::Server::Simple`, but has a very different internal API, and extended functionality. It's been designed to work well with the `Web::App` and `SCGI` libraries.

## HTTP::Easy

A role to build HTTP daemon classes with. This provides the framework for parsing HTTP connections.

## HTTP::Easy::PSGI

A class consuming the `HTTP::Easy` role. This builds a PSGI environment, and passes it onto a handler. The handler must return a `PSGI` response:

```
[ $status, @headers, @body ]

```

This can be used as an engine in the `Web::App` library.

## Example

```
use HTTP::Easy::PSGI;
my $http = HTTP::Easy::PSGI.new(:port(8080));

my $app = sub (%env) {
    my $name = %env<QUERY_STRING> || "World";
    [ 200, [ 'Content-Type' => 'text/plain' ], [ "Hello $name" ] ]
}

$http.handle($app);

```

# TODO

Implement HTTP/1.1 features such as Transfer-Encoding, etc.

# AUTHOR

Timothy Totten

# COPYRIGHT AND LICENSE

Copyright 2011 - 2017 Timothy Totten

Copyright 2018 - 2022 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-patrickb-RakudoContainerfileBuilder.md
# Rakudo Containerfile Builder

A small script to build *Containerfile* s that can create Rakudo container
images. Currently images are based on Alpine.

The resulting images have approximately the following sizes:

* `rakudo`: 71MB
* `rakudo-zef`: 280MB (also includes build tools required to install modules
  with native code)
* `rakudo-perl`: 130MB (includes a Perl suitable for use with `Inline::Perl5`)
* `rakudo-zef-perl`: 339MB (includes Zef and Perl)

Containers based on these are recommended to be *Multi Stage* d and use
`rakudo-zef` in the build stage and a plain `alpine` (or `rakudo-perl` should a
perl be necessary) in the final stage.

The following example Containerfile showcases that.

```
# BUILD STAGE #########################
FROM rakudo-zef:2020.12 AS build

RUN mkdir /app
WORKDIR /app

# Install deps separately first to not trash the podman cache on every
# source change.
COPY META6.json .
RUN zef install --deps-only .

# Now copy and compile the actual app.
COPY . .
RUN raku -c -I. service.raku

# FINAL STAGE #########################
FROM alpine:3.13.1

# Copy over app and Raku installation
COPY --from=build /app /app
COPY --from=build /usr/local /usr/local

WORKDIR /app

# Update path to make raku executables available
ENV PATH=$PATH:/usr/local/share/perl6/site/bin

ENV MY_APP_HOST="0.0.0.0" \
    MY_APP_PORT="10000"

EXPOSE 10000
CMD raku -I. service.raku

```


## dist_github-fayland-Locale-Codes.md
# perl6-Locale-Codes

[![Build Status](https://travis-ci.org/fayland/perl6-Locale-Codes.svg?branch=master)](https://travis-ci.org/fayland/perl6-Locale-Codes)

## SYNOPSIS

```
use Locale::Country;

my $country = code2country('JP'); # 'Japan'
my $code = country2code('Norway'); # 'NO'
my @codes = all_country_codes();
my @names = all_country_names();

use Locale::Currency;

my $currency = code2currency('usd'); # 'US Dollar'
my $code = currency2code('Euro'); # 'EUR'
my @codes = all_currency_codes();
my @names = all_currency_names();

use Locale::Language;

my $language = code2language('EN'); # 'English'
my $code = language2code('French'); # 'FR'
my @codes = all_language_codes();
my @names = all_language_names();

```

## Locale::Country

supports

* alpha-2, LOCALE\_CODE\_ALPHA\_2
* alpha-3, LOCALE\_CODE\_ALPHA\_3
* numeric, LOCALE\_CODE\_NUMERIC

### code2country

```
my $country = code2country('JP'); # 'Japan'
my $country = code2country('CHN'); # 'China'
my $country = code2country('250'); # 'France'

```

### country2code

```
my $code = country2code('Norway'); # 'NO', default alpha-2
my $code = country2code('Norway', LOCALE_CODE_ALPHA_2), 'NO';
my $code = country2code('Norway', 'numeric'); # '578'

```

### all\_country\_codes

```
my @codes = all_country_codes(); # alpha-2
my @codes = all_country_codes('alpha-3');
my @codes = all_country_codes(LOCALE_CODE_NUMERIC);

```

### all\_country\_names

```
my @names = all_country_names();

```

## Locale::Currency

supports

* alpha, LOCALE\_CURR\_ALPHA
* num, LOCALE\_CURR\_NUMERIC

### code2currency

```
my $currency = code2currency('usd'); # 'US Dollar'

```

### currency2code

```
my $code = currency2code('Euro'); # 'EUR'
my $code = currency2code('Euro', 'num'); # '978'

```

### all\_currency\_codes

```
my @codes = all_currency_codes(); # alpha
my @codes = all_currency_codes(LOCALE_CURR_NUMERIC);

```

### all\_currency\_names

```
my @names = all_currency_names();

```

## Locale::Language

supports

* alpha-2, LOCALE\_LANG\_ALPHA\_2
* alpha-3, LOCALE\_LANG\_ALPHA\_3
* term, LOCALE\_LANG\_TERM

### code2language

```
my $language = code2language('EN'); # 'English'
my $language = code2language('ENG', 'term'); # 'English'

```

### language2code

```
my $code = language2code('French'); # 'FR'
my $code = language2code('French', LOCALE_LANG_ALPHA_3); # 'FRE'

```

### all\_language\_codes

```
my @codes = all_language_codes(); # alpha
my @codes = all_language_codes(LOCALE_LANG_ALPHA_3);

```

### all\_language\_names

```
my @names = all_language_names();

```

## Locale::Script

supports

* alpha, LOCALE\_SCRIPT\_ALPHA
* num, LOCALE\_SCRIPT\_NUMERIC

### code2script

```
my $script = code2script('phnx'); # 'Phoenician'

```

### script2code

```
my $code = script2code('Phoenician'); # 'Phnx'
my $code = script2code('Phoenician', 'num'); # '115'

```

### all\_script\_codes

```
my @codes = all_script_codes(); # alpha
my @codes = all_script_codes(LOCALE_SCRIPT_NUMERIC);

```

### all\_script\_names

```
my @names = all_script_names();

```


## dist_zef-raku-community-modules-Getopt-Type.md
[![Actions Status](https://github.com/raku-community-modules/Getopt-Type/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/Getopt-Type/actions) [![Actions Status](https://github.com/raku-community-modules/Getopt-Type/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/Getopt-Type/actions) [![Actions Status](https://github.com/raku-community-modules/Getopt-Type/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/Getopt-Type/actions)

# NAME

Getopt::Type - MAIN? Getopt semantics? Why not both?

# SYNOPSIS

```
use Getopt::Type;

sub MAIN(*%opts where getopt(<f|force v|verbose>)) {
    say "Forcing!"   if %opts<force>;
    say "Verbosing!" if %opts<verbose>;
    say %opts.raku;
}

```

# DESCRIPTION

MAIN? Getopt semantics? Why not both?

# AUTHOR

Tadeusz Sośnierz

# COPYRIGHT AND LICENSE

Copyright 2016 - 2017 Tadeusz Sośnierz

Copyright 2024 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_cpan-JNTHN-OpenAPI-Schema-Validate.md
# OpenAPI::Schema::Validate

Validates a value or data structure (of hashes and arrays) against an OpenAPI
schema definition.

## Synopsis

```
use OpenAPI::Schema::Validate;

# A schema should have been deserialized into a hash at the top level.
# It will have been if you use this with OpenAPI::Model.
my $schema = OpenAPI::Schema::Validate.new(
    schema => from-json '{ "type": "string" }'
);

# Validate it and use the result as a boolean.
say so $schema.validate("foo");     # True
say so $schema.validate(42);        # False
say so $schema.validate(Str);       # False

# Validate it in sink context; Failure throws if there's a validation
# error; catch it and us the `reason` property for diagnostics.
for "foo", 42, Str -> $test {
    $schema.validate($est);
    say "$test.perl() is valid";
    CATCH {
        when X::OpenAPI::Schema::Validate::Failed {
            say "$test.perl() is not valid at $_.path(): $_.reason()";
        }
    }
}

```

## Methods

### new(:%schema!, :%formats, :%add-formats)

Constructs a schema validation object, checking the schema for any errors
(for example, properties having the wrong type of value, or `pattern` using
regex syntax beyond that allowed by the OpenAPI specification).

By default, the following values of `format` are recognized and enforced:

* `date-time` (as defined by date-time in RFC3339)
* `date` (as defined by full-date in RFC3339)
* `time` (as defined by full-time in RFC3339)
* `email` (as defined by RFC5322, section 3.4.1)
* `idn-email` (as defined by RFC6531)
* `hostname` (as defined by RFC1034 section 3.1, including host names produced
  using the Punycode algorithm specified in RFC5891 section 4.4)
* `idn-hostname` (as defined by either RFC1034 as for hostname, or an
  internationalized hostname as defined by RFC5890, section 2.3.2.3).
* `ipv4` (an IPv4 address according to the "dotted-quad" ABNF syntax as
  defined in RFC2673 section 3.2)
* `ipv6` (an IPv6 address as defined in RFC4291 section 2.2)
* `uri` (a valid URI as defiend by RFC3986)
* `uri-reference` (a valid URI or relative-reference as defined by RFC3986)
* `iri` (a valid IRI as defined by RFC3987)
* `iri-reference` (a valid IRI or relative-reference as defiend by RFC3987)
* `uri-template` (a valid URI template as defined by RFC6570)
* `json-pointer` (a valid representation of a JSON pointer as defiend by
  RFC6901 section 5)
* `relative-json-pointer` (a valid representation of a `relative-json-pointer`
  as defined by RFC6901)
* `regex` (a valid regex according to the ECMA 262 regular expression dialect)
* `int32` (range check)
* `int64` (range check)
* `binary` (when `string` type and `binary` format are used, then instead of
  checking for `Str`, we check for `Blob`)

All other `format` strings are ignored. However, it is possible to extend the
validator to support additional formats by passing a hash as the `add-formats`
named argument. The keys are the additional format to support, and the value
will be something used in a smartmatch against the value being validated. The
most common choices for this will be `Regex` or a `Block`.

```
    my $schema = OpenAPI::Schema::Validate.new(
        schema => from-json '{ "type": "string" }',
        add-formats => {
            isbn => /^(97(8|9))?\d{9}(\d|X)$/,
            percentage => { 0 <= $_ <= 100 }
        }
    );

```

Passing `formats` allows complete control over the formats that are validated.
To disable all format validation, pass `formats => {}`.

### validate($value, :$read, :$write)

Performs validation of the passed value. Returns `True` if the validation is
successful, and a `Failure` if it is unsuccessful. This allows use in both a
boolean context, or a sink context in which case the failiure will be sunk and
an exception of type `X::OpenAPI::Schema::Validate::Failed` thrown.

OpenAPI schemas may contain the `readOnly` and `writeOnly` properties. These
are used for properties that may only show up in responses and requets
respectively. Thus, pass `:read` when validating a response, and `:write` when
validating a request, in order to allow the appropriate properties to pass (or
fail) validation. If neither of `:read` and `:write` are passed then both
`readOnly` and `writeOnly` will always fail.