File Coverage

blib/lib/Pg/ServiceFile.pm
Criterion Covered Total %
statement 20 20 100.0
branch 3 4 75.0
condition n/a
subroutine 10 10 100.0
pod n/a
total 33 34 97.0


line stmt bran cond sub pod time code
1             package Pg::ServiceFile;
2              
3 1     1   43038 use Moo;
  1         10006  
  1         4  
4 1     1   1564 use Config::Pg::ServiceFile;
  1         28934  
  1         29  
5 1     1   447 use Types::Standard qw/ArrayRef HashRef Str/;
  1         57480  
  1         7  
6 1     1   1159 use Types::Path::Tiny 'Path';
  1         17737  
  1         6  
7              
8             # ABSTRACT: Basic PostgreSQL connection service file interface
9              
10             our $VERSION = '0.03';
11              
12             has data => (
13             is => 'lazy',
14             isa => Str,
15             );
16              
17             has file => (
18             is => 'lazy',
19             isa => Path,
20             coerce => 1,
21             );
22              
23             has name => (
24             is => 'lazy',
25             isa => Str,
26             );
27              
28             has names => (
29             is => 'lazy',
30             isa => ArrayRef,
31             );
32              
33             has service => (
34             is => 'lazy',
35             isa => HashRef,
36             );
37              
38             has services => (
39             is => 'lazy',
40             isa => HashRef,
41             );
42              
43 2     2   40 sub _build_data { shift->file->slurp_utf8 }
44              
45 1 50   1   3941 sub _build_file { $ENV{PGSERVICEFILE} || '~/.pg_service.conf'}
46              
47 2 100   2   4923 sub _build_name { $ENV{PGSERVICE} || '' }
48              
49 2     2   4753 sub _build_names { [sort keys %{shift->services}] }
  2         28  
50              
51             sub _build_service {
52 1     1   379 my $self = shift;
53 1         15 return $self->services->{$self->name};
54             }
55              
56 5     5   11867 sub _build_services { Config::Pg::ServiceFile->read_string(shift->data) }
57              
58             1;
59              
60             __END__