| 1 | package Etcd::Node; | ||||||||||
| 2 | 5 | $Etcd::Node::VERSION = '0.003'; | |||||||||
| 3 | 5 | ▶ | use namespace::sweep; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 5 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | ▶ | use Type::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 5 | ▶ | use Types::Standard qw(Int Str Bool ArrayRef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 5 | ▶ | use Type::Utils qw(class_type); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | # http://www.pelagodesign.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/ | ||||||||||
| 11 | 5 | my $ISO8601 = do { | |||||||||
| 12 | 5 | my $iso8601_re = qr{^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$}; | |||||||||
| 13 | Type::Tiny->new( | ||||||||||
| 14 | name => "ISO8601", | ||||||||||
| 15 | 0 | ▶ | constraint => sub { m/$iso8601_re/ }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 16 | 5 | ▶ | inlined => sub { "$_[1] =~ m/$iso8601_re/" }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 5 | ); | |||||||||
| 18 | }; | ||||||||||
| 19 | |||||||||||
| 20 | 5 | has key => ( is => 'ro', isa => Str, required => 1 ); | |||||||||
| 21 | 5 | has value => ( is => 'ro', isa => Str ); | |||||||||
| 22 | 5 | has created_index => ( is => 'ro', isa => Int, init_arg => 'createdIndex' ); | |||||||||
| 23 | 5 | has modified_index => ( is => 'ro', isa => Int, init_arg => 'modifiedIndex' ); | |||||||||
| 24 | 5 | has ttl => ( is => 'ro', isa => Int ); | |||||||||
| 25 | 5 | has expiration => ( is => 'ro', isa => $ISO8601 ); | |||||||||
| 26 | 4 | ▶ | has dir => ( is => 'ro', isa => Bool, coerce => sub { !! $_[0] } ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | has nodes => ( | ||||||||||
| 29 | is => 'ro', | ||||||||||
| 30 | isa => ArrayRef[class_type('Etcd::Node')], | ||||||||||
| 31 | 0 | ▶ | coerce => sub { ref $_[0] eq "ARRAY" ? [ map { Etcd::Node->new(%$_) } @{$_[0]} ] : $_[0] } | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 32 | 5 | ); | |||||||||
| 33 | |||||||||||
| 34 | 5 | 1; | |||||||||
| 35 | |||||||||||
| 36 | __END__ | ||||||||||