blib/lib/HPC/Runner/Command/Logger/JSON.pm

filter: Statementstmt 47.0% 24 / 51 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 1 totaltotal 45.5% 31 / 68 CC 4 SCAR 19.5
CC
4
Cov
42%
create_data_dir
20.0
__ANON__
2.0
__ANON__
2.0
CRAP 7.0
« blib/lib/HPC/Runner/Command/stats/Logger/JSON/Long/JSONOutput.pm ↑ Summary blib/lib/HPC/Runner/Command/execute_job/Logger/Lock.pm »
1 package HPC::Runner::Command::Logger::JSON;
2  
3 1 ▶use MooseX::App::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use MooseX::Types::Path::Tiny qw/File Path Paths AbsPath AbsFile/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Data::UUID;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Path qw(make_path remove_tree);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use HPC::Runner::Command::Logger::JSON::Archive;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with 'BioSAILs::Utils::Files::CacheDir';
12  
13 option 'data_dir' => (
14 is => 'rw',
15 isa => AbsPath,
16 lazy => 1,
17 coerce => 1,
18 required => 1,
19 documentation => q{Data directory for hpcrunner},
20 predicate => 'has_data_dir',
21 default => sub {
22 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 my $path = $self->create_data_dir;
24 0 $ENV{HPC_DATA_DIR} = $path;
25 0 return $path;
26 },
27 trigger => sub {
28 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 0 make_path( $self->data_dir );
30 0 $ENV{HPC_DATA_DIR} = $self->data_dir->stringify;
31 },
32 1 );
33  
34 sub create_data_dir {
35 0 ▶ my $self = shift;
Subroutine create_data_dir: not called CC=4 SCAR=30.0
Pod undocumented
36  
37 0 ▶ if ( $self->has_data_dir ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_data_dir) 0 0 0
38 0 make_path( $self->data_dir);
39 0 return;
40 }
41  
42 0 my $data_dir = File::Spec->catdir( $self->cache_dir, '.hpcrunner-data' );
43 0 my $project = "NULL_PROJECT";
44 0 ▶ $project = $self->project if $self->has_project;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_project 0 0 0
45  
46 ##Create initial document
47 0 my $dt = DateTime->now( time_zone => 'local' );
48 0 $dt = "$dt";
49 0 $dt =~ s/:/-/g;
50  
51 0 my $ug = Data::UUID->new;
52 0 my $uuid = $ug->create();
53 0 $uuid = $ug->to_string($uuid);
54  
55 0 $self->submission_uuid($uuid);
56  
57 0 my $path = File::Spec->catdir( $data_dir, $project );
58 0 make_path($path);
59  
60 0 ▶ if ( $self->has_project ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_project) { } 0 0 0
61 0 $path =
62 File::Spec->catdir( $data_dir, $project,
63 $dt . '__PR_' . $project . '__UID_' . $uuid );
64 }
65 else {
66 0 $path =
67 File::Spec->catdir( $data_dir, $project, $dt . '__UID_' . $uuid );
68 }
69  
70 0 return $path;
71 }
72  
73 1 1;
« blib/lib/HPC/Runner/Command/stats/Logger/JSON/Long/JSONOutput.pm ↑ Summary blib/lib/HPC/Runner/Command/execute_job/Logger/Lock.pm »