| 1 | package App::Prove::Elasticsearch::Provisioner::Perl; | ||||||||||
| 2 | 2 | $App::Prove::Elasticsearch::Provisioner::Perl::VERSION = '0.001'; | |||||||||
| 3 | |||||||||||
| 4 | # PODNAME: App::Prove::Elasticsearch::Provisioner::Perl; | ||||||||||
| 5 | # ABSTRACT: Provision perl on your SUT | ||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use App::perlbrew; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use Perl::Version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | sub get_available_provision_targets { | ||||||||
|
Subroutine
get_available_provision_targets: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 14 | 2 | my ($cv) = @_; | |||||||||
| 15 | 2 | my $pb = App::perlbrew->new('list'); | |||||||||
| 16 | 2 | my @perls = $pb->available_perls(); | |||||||||
| 17 | 2 | ▶ | no warnings 'numeric'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | @perls = grep { | ||||||||||
| 19 | 2 | ▶ | my $v_sanitized = $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 2 | $v_sanitized =~ s/c?perl-?//g; | |||||||||
| 21 | 2 | $v_sanitized =~ s/\.0/\./g; #remove leading zero from ancient perls | |||||||||
| 22 | 2 | Perl::Version->new(sprintf("%.3f", $cv)) != | |||||||||
| 23 | Perl::Version->new(sprintf("%.2f", $v_sanitized)) | ||||||||||
| 24 | } @perls if $cv; | ||||||||||
| 25 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 2 | return @perls; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 1 | ▶ | sub pick_platform { | ||||||||
|
Subroutine
pick_platform: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 30 | 1 | my (@plats) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 1 | my $plat; | |||||||||
| 33 | 1 | foreach my $p (@plats) { | |||||||||
| 34 | 4 | ▶ | if ($p =~ m/^perl/i) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 1 | $plat = $p; | |||||||||
| 36 | 1 | @plats = grep { $_ ne $p } @plats; | |||||||||
| 37 | 1 | last; | |||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | 1 | return $plat, \@plats; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | sub can_switch_version { | ||||||||
|
Subroutine
can_switch_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 44 | 1 | return 0; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 1 | ▶ | sub switch_version_to { | ||||||||
|
Subroutine
switch_version_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 48 | 1 | die "Can't switch version via changing perl interpreter."; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | sub provision { | ||||||||
|
Subroutine
provision: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | 1 | my ($desired_platform) = @_; | |||||||||
| 53 | 1 | my $pb = App::perlbrew->new('install'); | |||||||||
| 54 | 1 | $pb->run_command_install($desired_platform); | |||||||||
| 55 | |||||||||||
| 56 | #This *should*? be enough magic to 'do the deed' | ||||||||||
| 57 | 1 | %ENV = $pb->perlbrew_env($desired_platform); | |||||||||
| 58 | 1 | return $desired_platform; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 2 | 1; | |||||||||
| 62 | |||||||||||
| 63 | __END__ | ||||||||||