| 1 | package Carmel::Environment; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carmel::CPANfile; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carmel::Repository; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Class::Tiny { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||
| 10 | 0 | ▶ | perl_arch => sub { "$Config{version}-$Config{archname}" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | repository_base => sub { $_[0]->build_repository_base }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | repo => sub { $_[0]->build_repo }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | home => sub { Path::Tiny->new($ENV{HOME} || $ENV{HOMEPATH}) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$ENV{'HOME'} || $ENV{'HOMEPATH'}
MC/DC0%0/2
$ENV{'HOME'} || $ENV{'HOMEPATH'}
$ENV{'HOME'}
$ENV{'HOMEPATH'}
Truth table0%0/3
A || B
A= $ENV{'HOME'}B= $ENV{'HOMEPATH'}
| |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | cpanfile => sub { $_[0]->build_cpanfile }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | snapshot => sub { $_[0]->build_snapshot }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 16 | 1 | }; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub build_repository_base { | ||||||||||||||||||||||||||
|
Subroutine
build_repository_base: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | Path::Tiny->new($ENV{PERL_CARMEL_REPO} || $self->home->child(".carmel/" . $self->perl_arch)); | ||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{'PERL_CARMEL_REPO'} || $self->home->child('.carmel/' . $self->perl_arch)
MC/DC0%0/2
$ENV{'PERL_CARMEL_REPO'} || $self->home->child('.carmel/' . $self->perl_arch)
$ENV{'PERL_CARMEL_REPO'}
$self->home->child('.carmel/' . $self->perl_arch)
Truth table0%0/3
A || B
A= $ENV{'PERL_CARMEL_REPO'}B= $self->home->child('.carmel/' . $self->perl_arch)
| |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub build_repo { | ||||||||||||||||||||||||||
|
Subroutine
build_repo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 0 | Carmel::Repository->new(path => $self->repository_base->child('builds')); | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub build_cpanfile { | ||||||||||||||||||||||||||
|
Subroutine
build_cpanfile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | 0 | my $path = Path::Tiny->new($self->locate_cpanfile); | |||||||||||||||||||||||||||
| 31 | 0 | Carmel::CPANfile->new(path => $path->absolute); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub locate_cpanfile { | ||||||||||||||||||||||||||
|
Subroutine
locate_cpanfile: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | my $path = $ENV{PERL_CARMEL_CPANFILE}; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | return $path; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my $current = Path::Tiny->cwd; | |||||||||||||||||||||||||||
| 43 | 0 | my $previous = ''; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | until ($current eq '/' or $current eq $previous) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$current eq "/" or $current eq $previous
MC/DC0%0/2
$current eq "/" or $current eq $previous
$current eq "/"
$current eq $previous
Truth table0%0/3
A or B
A= $current eq "/"B= $current eq $previous
| |||||||||||||||||||||||||||||
| 46 | 0 | my $try = $current->child('cpanfile'); | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | return $try if $try->is_file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 0 | ($previous, $current) = ($current, $current->parent); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | return 'cpanfile'; # fallback, most certainly fails later | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub build_snapshot { | ||||||||||||||||||||||||||
|
Subroutine
build_snapshot: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my $path = $self->snapshot_path; | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ($path && $path->exists) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$path and $path->exists
MC/DC0%0/2
$path and $path->exists
$path
$path->exists
Truth table0%0/3
A and B
A= $pathB= $path->exists
| |||||||||||||||||||||||||||||
| 59 | 0 | require Carton::Snapshot; | |||||||||||||||||||||||||||
| 60 | 0 | my $snapshot = Carton::Snapshot->new(path => $path); | |||||||||||||||||||||||||||
| 61 | 0 | $snapshot->load; | |||||||||||||||||||||||||||
| 62 | 0 | return $snapshot; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | return; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub snapshot_path { | ||||||||||||||||||||||||||
|
Subroutine
snapshot_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 0 | Path::Tiny->new($self->cpanfile->path . ".snapshot"); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | 1; | |||||||||||||||||||||||||||