Chado/DBManager/Postgression.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Chado/Role/HasDBManager.pm ↑ Summary Chado/FixtureLoader/Flatfile.pm »
1 package Test::Chado::DBManager::Postgression;
2 {
3 $Test::Chado::DBManager::Postgression::VERSION = 'v4.1.1';
4 }
5  
6 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 0 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=2.6
11 use feature qw/say/;
12 extends qw/Test::Chado::DBManager::Pg/;
13  
14 sub _build_dbh {
15 my ($self) = @_;
16 my $ua = HTTP::Tiny->new(
17 default_headers => { 'Accept' => 'application/json' } );
18 my $response = $ua->get('http://api.postgression.com');
19  
20 if (!$response->{success}) {
21 say "request to postgression failed !!!!";
22 die "status: $response->{status}\treason: $response->{reason}\n";
23 }
24  
25 my $resp_hash = decode_json $response->{content};
26 my $dsn
27 = "dbi:Pg:dbname=$resp_hash->{dbname};host=$resp_hash->{host};port=$resp_hash->{port}";
28 $self->dsn($dsn);
29 $self->user( $resp_hash->{username} );
30 $self->password( $resp_hash->{password} );
31  
32 my $attr = $self->dbi_attributes;
33 $attr->{AutoCommit} = 1;
34 my $dbh = DBI->connect( $self->dsn, $self->user, $self->password, $attr );
35 $dbh->do(qq{SET client_min_messages=WARNING});
36 return $dbh;
37 }
38  
39 1;
40  
41 __END__
« Chado/Role/HasDBManager.pm ↑ Summary Chado/FixtureLoader/Flatfile.pm »