package Pakket::Constants; ## no critic (Subroutines::ProhibitExportingUndeclaredSubs)
# ABSTRACT: Constants used in Pakket

use strict;
use warnings;
use parent 'Exporter';

use constant {
    'PARCEL_EXTENSION'     => 'pkt',
    'PARCEL_FILES_DIR'     => 'files',
    'PARCEL_METADATA_FILE' => 'meta.json',

    # CATEGORY/PACKAGE         == latest version
    # CATEGORY/PACKAGE=VERSION == Exact version
    'PAKKET_PACKAGE_SPEC'  => qr{
        ^
        ([^/]+)     # category
        /
        ([^=]+)    # name
        (?:
            =
            (.+) # optional version
        )?
        $
    }xms,

    'PAKKET_LATEST_VERSION' => 'LATEST',

    'PAKKET_INFO_FILE'      => 'info.json',
};

our @EXPORT_OK = qw<
    PARCEL_EXTENSION
    PARCEL_FILES_DIR
    PARCEL_METADATA_FILE
    PAKKET_PACKAGE_SPEC
    PAKKET_LATEST_VERSION
    PAKKET_INFO_FILE
>;

1;

package Pakket::Constants; ## no critic (Subroutines::ProhibitExportingUndeclaredSubs)
# ABSTRACT: Constants used in Pakket

use strict;
use warnings;
use parent 'Exporter';

use constant {
    'PARCEL_EXTENSION'     => 'pkt',
    'PARCEL_FILES_DIR'     => 'files',
    'PARCEL_METADATA_FILE' => 'meta.json',

    # CATEGORY/PACKAGE                 == latest version, latest release
    # CATEGORY/PACKAGE=VERSION         == Exact version, latest release
    # CATEGORY/PACKAGE=VERSION:RELEASE == Exact version and release
    'PAKKET_PACKAGE_SPEC'  => qr{
        ^
        ( [^/]+ )       # category
        /
        ( [^=]+ )       # name
        (?:
            =
            ( [^:]+ )   # optional version
            (?:
                :
                (.*)    # optional release
            )?
        )?
        $
    }xms,

    'PAKKET_LATEST_VERSION' => 'LATEST',

    'PAKKET_INFO_FILE'      => 'info.json',
};

our @EXPORT_OK = qw<
    PARCEL_EXTENSION
    PARCEL_FILES_DIR
    PARCEL_METADATA_FILE
    PAKKET_PACKAGE_SPEC
    PAKKET_LATEST_VERSION
    PAKKET_INFO_FILE
>;

1;

Add Release data to the string spec:
Add Release data to the string spec:

"Release" is added to the string spec, so we can now parse a string
for any possible release.

There is one caveat: A version number cannot contain a colon.
