File Coverage

blib/lib/Etcd/Stats.pm
Criterion Covered Total %
statement 15 19 78.9
branch 0 2 0.0
condition 0 3 0.0
subroutine 5 7 71.4
pod 0 1 0.0
total 20 32 62.5


line stmt bran cond sub pod time code
1             package Etcd::Stats;
2             $Etcd::Stats::VERSION = '0.002';
3 4     4   1881 use namespace::sweep;
  4         8  
  4         24  
4              
5 4     4   249 use JSON qw(decode_json);
  4         7  
  4         30  
6 4     4   404 use Carp qw(croak);
  4         7  
  4         150  
7              
8 4     4   14 use Moo::Role;
  4         4  
  4         19  
9 4     4   928 use Types::Standard qw(Str);
  4         5  
  4         20  
10              
11             requires qw(version_prefix api_exec);
12              
13             has _stats_endpoint => ( is => 'lazy', isa => Str );
14             sub _build__stats_endpoint {
15 0     0     shift->version_prefix . '/stats';
16             }
17              
18             # XXX should return real objects
19             sub stats {
20 0     0 0   my ($self, $type, %args) = @_;
21 0 0 0       croak 'usage: $etcd->type("leader|store|self", [%args])' if !defined $type || $type !~ m/^(?:leader|store|self)$/;
22 0           decode_json($self->api_exec($self->_stats_endpoint."/$type", 'GET', %args)->{content});
23             }
24              
25             1;
26              
27             __END__