Commit | Line | Data |
ceef0cf1 |
1 | package Gitalist::Git::Types; |
2 | |
3 | use MooseX::Types |
5c07fcf1 |
4 | -declare => [qw/ |
5 | SHA1 |
5c07fcf1 |
6 | Dir |
7 | /]; |
ceef0cf1 |
8 | |
5c07fcf1 |
9 | use MooseX::Types::Path::Class; |
10 | use MooseX::Types::ISO8601 qw/ISO8601DateTimeStr/; |
f9baba96 |
11 | use MooseX::Types::DateTime qw/ DateTime /; |
5c07fcf1 |
12 | use MooseX::Storage::Engine (); |
ceef0cf1 |
13 | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; |
14 | |
15 | subtype SHA1, |
16 | as NonEmptySimpleStr, |
17 | where { $_ =~ qr/^[0-9a-fA-F]{40}$/ }, |
18 | message { q/Str doesn't look like a SHA1./ }; |
19 | |
20 | coerce SHA1, |
21 | from NonEmptySimpleStr, |
22 | via { 1 }; |
23 | |
5c07fcf1 |
24 | MooseX::Storage::Engine->add_custom_type_handler( |
25 | DateTime, |
26 | expand => sub { |
27 | my $val = shift; |
28 | Carp::confess("Not implemented"); |
29 | }, |
30 | collapse => sub { |
31 | to_ISO8601DateTimeStr(shift); |
32 | }, |
33 | ); |
34 | |
35 | subtype Dir, |
36 | as 'MooseX::Types::Path::Class::Dir', |
37 | where { 1 }; |
38 | |
39 | MooseX::Storage::Engine->add_custom_type_handler( |
40 | Dir, |
41 | expand => sub { |
42 | my $val = shift; |
43 | Carp::confess("Not implemented"); |
44 | }, |
45 | collapse => sub { |
46 | shift() . ''; |
47 | }, |
48 | ); |
49 | |
ceef0cf1 |
50 | 1; |