File Coverage

blib/lib/XML/SRS/Date.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1              
2             package XML::SRS::Date;
3              
4 1     1   1680 use Moose::Role;
  0            
  0            
5             use PRANG::Graph;
6             use Moose::Util::TypeConstraints;
7             use MooseX::Method::Signatures;
8              
9             BEGIN {
10             subtype "XML::SRS::Date::ymd"
11             => as "Str"
12             => where {
13             m{^(\d{4})-(\d{1,2})-(\d{1,2})$};
14             };
15              
16             subtype 'XML::SRS::Date::Year'
17             => as "Int",
18             => where {
19             length(0+$_) == 4;
20             };
21             subtype 'XML::SRS::Date::Month'
22             => as "Int",
23             => where {
24             $_ >= 1 and $_ <= 12;
25             };
26             subtype 'XML::SRS::Date::Day'
27             => as "Str",
28             => where {
29             $_ >= 1 and $_ <= 31;
30             };
31             }
32              
33             has_attr 'year' =>
34             is => "rw",
35             isa => "XML::SRS::Number",
36             required => 1,
37             xml_name => "Year",
38             ;
39              
40             has_attr 'month' =>
41             is => "rw",
42             isa => "XML::SRS::Number",
43             required => 1,
44             xml_name => "Month",
45             ;
46              
47             has_attr 'day' =>
48             is => "rw",
49             isa => "XML::SRS::Number",
50             required => 1,
51             xml_name => "Day",
52             ;
53              
54             method buildargs_date($inv: XML::SRS::Date::ymd $ymd) {
55             my @buildargs;
56             my ($y, $m, $d) = split "-", $ymd;
57             push @buildargs, year => $y, month => $m, day => $d;
58             @buildargs;
59             }
60              
61             1;