File Coverage

blib/lib/CloudDeploy/Config.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package CloudDeploy::Config {
2 14     14   108 use Moose;
  14         34  
  14         116  
3 14     14   107783 use MongoDB;
  14         24641654  
  14         6848  
4              
5             has account => (is => 'ro', isa => 'Str', required => 1, default => sub { $ENV{CPSD_AWS_ACCOUNT} });
6              
7             has deploy_server => (is => 'ro', lazy => 1, default => sub { $ENV{DEPLOY_SERVER} or 'mongodb://localhost:27017' });
8             has mongo_client => (is => 'ro', lazy => 1, default => sub {
9             MongoDB::MongoClient->new(host => shift->deploy_server);
10             });
11              
12             has deploy_mongo => (is => 'ro', lazy => 1, default => sub {
13             my $self = shift;
14             return $self->mongo_client->get_database($self->deploy_db)->get_collection($self->deploy_collection);
15             });
16             has deploylog_mongo => (is => 'ro', lazy => 1, default => sub {
17             my $self = shift;
18             return $self->mongo_client->get_database($self->deploy_db)->get_collection($self->deploylog_collection);;
19             });
20              
21             has deploy_db => (is => 'ro', lazy => 1, default => sub { $ENV{DEPLOY_DB} or 'clouddeploy' });
22             has deploy_collection => (is => 'ro', lazy => 1, default => sub { $ENV{DEPLOY_COLLECTION} or 'deployments' });
23             has deploylog_collection => (is => 'ro', lazy => 1, default => sub { shift->deploy_collection . "_log" });
24             has ami_db => (is => 'ro', lazy => 1, default => sub { $_[0]->deploy_db });
25             has ami_collection => (is => 'ro', lazy => 1, default => sub { $ENV{AMI_COLLECTION} or 'amis' });
26             has ami_mongo => (is => 'ro', lazy => 1, default => sub {
27             my $self = shift;
28             return $self->mongo_client->get_database($self->ami_db)->get_collection($self->ami_collection);
29             });
30             has amilog_mongo => (is => 'ro', lazy => 1, default => sub {
31             my $self = shift;
32             return $self->mongo_client->get_database($self->ami_db)->get_collection($self->ami_collection);
33             });
34             }
35             1;