| 1 | package Enum::Declare::Common; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.014; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | our $VERSION = '1.00'; | |
| 8 | |||
| 9 | 1 | 1; | |
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | Enum::Declare::Common - A curated collection of commonly-needed enums | ||
| 14 | |||
| 15 | =head1 VERSION | ||
| 16 | |||
| 17 | Version 1.00 | ||
| 18 | |||
| 19 | =head1 SYNOPSIS | ||
| 20 | |||
| 21 | use Enum::Declare::Common::HTTP; | ||
| 22 | use Enum::Declare::Common::Calendar; | ||
| 23 | |||
| 24 | # HTTP status codes | ||
| 25 | my $meta = StatusCode(); | ||
| 26 | say OK; # 200 | ||
| 27 | say NotFound; # 404 | ||
| 28 | |||
| 29 | # HTTP methods | ||
| 30 | say GET; # "get" | ||
| 31 | |||
| 32 | # Calendar | ||
| 33 | say Monday; # 1 | ||
| 34 | say January; # 1 | ||
| 35 | |||
| 36 | =head1 DESCRIPTION | ||
| 37 | |||
| 38 | Enum::Declare::Common provides a collection of frequently used enums built on | ||
| 39 | L<Enum::Declare>. Each submodule declares standard enums with proper | ||
| 40 | constants, export support, and meta objects for introspection and | ||
| 41 | exhaustive matching. | ||
| 42 | |||
| 43 | =head1 MODULES | ||
| 44 | |||
| 45 | =over 4 | ||
| 46 | |||
| 47 | =item * L<Enum::Declare::Common::HTTP> — HTTP status codes, methods, and helpers | ||
| 48 | |||
| 49 | =item * L<Enum::Declare::Common::Calendar> — Weekday, WeekdayFlag (bitmask), Month | ||
| 50 | |||
| 51 | =item * L<Enum::Declare::Common::Country> — ISO 3166-1 alpha-2/3 codes to country names | ||
| 52 | |||
| 53 | =item * L<Enum::Declare::Common::CountryISO> — ISO 3166-1 alpha-2/3 code-to-code constants | ||
| 54 | |||
| 55 | =item * L<Enum::Declare::Common::Currency> — ISO 4217 currency codes to names | ||
| 56 | |||
| 57 | =item * L<Enum::Declare::Common::CurrencyISO> — ISO 4217 code-to-code constants | ||
| 58 | |||
| 59 | =item * L<Enum::Declare::Common::MIME> — 48 common MIME types | ||
| 60 | |||
| 61 | =item * L<Enum::Declare::Common::Color> — 148 named CSS colours with hex values | ||
| 62 | |||
| 63 | =item * L<Enum::Declare::Common::Sort> — Direction (Asc/Desc) and NullHandling | ||
| 64 | |||
| 65 | =item * L<Enum::Declare::Common::Bool> — YesNo, OnOff, TrueFalse, Bit | ||
| 66 | |||
| 67 | =item * L<Enum::Declare::Common::Priority> — Level (1-5) and Severity strings | ||
| 68 | |||
| 69 | =item * L<Enum::Declare::Common::Timezone> — Timezone abbreviation constants | ||
| 70 | |||
| 71 | =item * L<Enum::Declare::Common::TimezoneOffset> — UTC offsets in seconds | ||
| 72 | |||
| 73 | =item * L<Enum::Declare::Common::Locale> — Language/locale tag constants | ||
| 74 | |||
| 75 | =item * L<Enum::Declare::Common::FileType> — File type constants | ||
| 76 | |||
| 77 | =item * L<Enum::Declare::Common::Encoding> — Character encoding names | ||
| 78 | |||
| 79 | =item * L<Enum::Declare::Common::Permission> — Unix permission bits and masks | ||
| 80 | |||
| 81 | =item * L<Enum::Declare::Common::Environment> — Application environment names | ||
| 82 | |||
| 83 | =item * L<Enum::Declare::Common::LogLevel> — Numeric log levels for comparison | ||
| 84 | |||
| 85 | =item * L<Enum::Declare::Common::Status> — Lifecycle status strings | ||
| 86 | |||
| 87 | =back | ||
| 88 | |||
| 89 | =head1 USING WITH Object::Proto | ||
| 90 | |||
| 91 | Every enum in this collection is declared with the C<:Type> attribute, | ||
| 92 | which automatically registers it as an L<Object::Proto> type at load time. | ||
| 93 | This means you can use any enum name directly as a slot type: | ||
| 94 | |||
| 95 | use Enum::Declare::Common::HTTP qw(:StatusCode :Method); | ||
| 96 | use Enum::Declare::Common::LogLevel qw(:Level); | ||
| 97 | use Object::Proto; | ||
| 98 | |||
| 99 | object 'APIRequest', | ||
| 100 | 'method:Method:required', | ||
| 101 | 'status:StatusCode', | ||
| 102 | 'log_level:Level:default(' . Info . ')', | ||
| 103 | ; | ||
| 104 | |||
| 105 | my $req = new APIRequest method => GET; | ||
| 106 | $req->status(OK); # accepts valid enum value | ||
| 107 | $req->status(9999); # dies — not a valid StatusCode | ||
| 108 | |||
| 109 | Enum types support coercion, so case-insensitive name lookups work | ||
| 110 | automatically: | ||
| 111 | |||
| 112 | $req->status(200); # coerces integer to OK | ||
| 113 | |||
| 114 | B<Note:> Enum names must be unique across all loaded modules. For example, | ||
| 115 | C<Enum::Declare::Common::Bool> and C<Enum::Declare::Common::Permission> | ||
| 116 | both declare an enum named C<Bit>, so loading both in the same program | ||
| 117 | will cause a conflict. Import only the specific tags you need. | ||
| 118 | |||
| 119 | =head1 AUTHOR | ||
| 120 | |||
| 121 | LNATION C<< <email@lnation.org> >> | ||
| 122 | |||
| 123 | =head1 LICENSE AND COPYRIGHT | ||
| 124 | |||
| 125 | This software is Copyright (c) 2026 by LNATION C<< <email@lnation.org> >>. | ||
| 126 | |||
| 127 | This is free software, licensed under: | ||
| 128 | |||
| 129 | The Artistic License 2.0 (GPL Compatible) | ||
| 130 | |||
| 131 | =cut | ||
| 132 | |||
| 133 | 1 | 1; # End of Enum::Declare::Common | |