File Coverage

blib/lib/Enum/Declare/Common.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 11 11 100.0


line stmt bran cond sub pod time code
1             package Enum::Declare::Common;
2              
3 1     1   111218 use 5.014;
  1         3  
4 1     1   4 use strict;
  1         1  
  1         30  
5 1     1   3 use warnings;
  1         6  
  1         77  
6              
7             our $VERSION = '0.02';
8              
9             1;
10              
11             =head1 NAME
12              
13             Enum::Declare::Common - A curated collection of commonly-needed enums
14              
15             =head1 VERSION
16              
17             Version 0.02
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. 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 — HTTP status codes, methods, and helpers
48              
49             =item * L — Weekday, WeekdayFlag (bitmask), Month
50              
51             =item * L — ISO 3166-1 alpha-2/3 codes to country names
52              
53             =item * L — ISO 3166-1 alpha-2/3 code-to-code constants
54              
55             =item * L — ISO 4217 currency codes to names
56              
57             =item * L — ISO 4217 code-to-code constants
58              
59             =item * L — 48 common MIME types
60              
61             =item * L — 148 named CSS colours with hex values
62              
63             =item * L — Direction (Asc/Desc) and NullHandling
64              
65             =item * L — YesNo, OnOff, TrueFalse, Bit
66              
67             =item * L — Level (1-5) and Severity strings
68              
69             =item * L — Timezone abbreviation constants
70              
71             =item * L — UTC offsets in seconds
72              
73             =item * L — Language/locale tag constants
74              
75             =item * L — File type constants
76              
77             =item * L — Character encoding names
78              
79             =item * L — Unix permission bits and masks
80              
81             =item * L — Application environment names
82              
83             =item * L — Numeric log levels for comparison
84              
85             =item * L — 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 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 Enum names must be unique across all loaded modules. For example,
115             C and C
116             both declare an enum named C, 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<< >>
122              
123             =head1 LICENSE AND COPYRIGHT
124              
125             This software is Copyright (c) 2026 by LNATION C<< >>.
126              
127             This is free software, licensed under:
128              
129             The Artistic License 2.0 (GPL Compatible)
130              
131             =cut
132              
133             1; # End of Enum::Declare::Common