| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::Rakubrew::Variables; | 
| 2 |  |  |  |  |  |  | require Exporter; | 
| 3 |  |  |  |  |  |  | our @ISA = qw( Exporter ); | 
| 4 |  |  |  |  |  |  | our @EXPORT = qw( $brew_name $brew_exec $env_var $local_filename $prefix $versions_dir $shim_dir $zef_dir $git_reference $GIT $GIT_PROTO $PERL5 %git_repos %impls ); | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 3 |  |  | 3 |  | 18 | use strict; | 
|  | 3 |  |  |  |  | 4 |  | 
|  | 3 |  |  |  |  | 74 |  | 
| 7 | 3 |  |  | 3 |  | 13 | use warnings; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 80 |  | 
| 8 | 3 |  |  | 3 |  | 44 | use 5.010; | 
|  | 3 |  |  |  |  | 10 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 3 |  |  | 3 |  | 406 | use FindBin qw($RealBin); | 
|  | 3 |  |  |  |  | 835 |  | 
|  | 3 |  |  |  |  | 294 |  | 
| 11 | 3 |  |  | 3 |  | 65 | use File::Spec::Functions qw(catfile catdir updir); | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 161 |  | 
| 12 | 3 |  |  | 3 |  | 16 | use Cwd qw(abs_path); | 
|  | 3 |  |  |  |  | 10 |  | 
|  | 3 |  |  |  |  | 115 |  | 
| 13 | 3 |  |  | 3 |  | 1211 | use File::HomeDir; | 
|  | 3 |  |  |  |  | 14460 |  | 
|  | 3 |  |  |  |  | 133 |  | 
| 14 | 3 |  |  | 3 |  | 999 | use App::Rakubrew::Config; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 1611 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | our $brew_name = 'rakubrew'; | 
| 17 |  |  |  |  |  |  | our $brew_exec = catfile($RealBin, $brew_name); | 
| 18 |  |  |  |  |  |  | if ($^O =~ /win32/i ) { | 
| 19 |  |  |  |  |  |  | $brew_exec .= $distro_format eq 'cpan' ? '.bat' : '.exe'; | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  | our $home_env_var = 'RAKUBREW_HOME'; | 
| 22 |  |  |  |  |  |  | our $env_var = 'RAKUBREW_VERSION'; | 
| 23 |  |  |  |  |  |  | our $local_filename = '.raku-version'; | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | our $prefix = $ENV{$home_env_var} | 
| 26 |  |  |  |  |  |  | // ($^O =~ /win32/i ? 'C:\rakubrew' | 
| 27 |  |  |  |  |  |  | : catdir(File::HomeDir->my_home, '.rakubrew')); | 
| 28 |  |  |  |  |  |  | $prefix = abs_path($prefix) if (-d $prefix); | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | our $versions_dir = catdir($prefix, 'versions'); | 
| 31 |  |  |  |  |  |  | our $shim_dir = catdir($prefix, 'shims'); | 
| 32 |  |  |  |  |  |  | our $git_reference = catdir($prefix, 'git_reference'); | 
| 33 |  |  |  |  |  |  | our $zef_dir = catdir($prefix, 'repos', 'zef'); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | our $GIT       = $ENV{GIT_BINARY} // 'git'; | 
| 36 |  |  |  |  |  |  | our $GIT_PROTO = $ENV{GIT_PROTOCOL} // 'https'; | 
| 37 |  |  |  |  |  |  | our $PERL5     = $^X; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub get_git_url { | 
| 40 | 12 |  |  | 12 | 0 | 22 | my ($protocol, $host, $user, $project) = @_; | 
| 41 | 12 | 50 |  |  |  | 19 | if ($protocol eq "ssh") { | 
| 42 | 0 |  |  |  |  | 0 | return "git\@${host}:${user}/${project}.git"; | 
| 43 |  |  |  |  |  |  | } else { | 
| 44 | 12 |  |  |  |  | 44 | return "${protocol}://${host}/${user}/${project}.git"; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | our %git_repos = ( | 
| 49 |  |  |  |  |  |  | rakudo => get_git_url($GIT_PROTO, 'github.com', 'rakudo', 'rakudo'), | 
| 50 |  |  |  |  |  |  | MoarVM => get_git_url($GIT_PROTO, 'github.com', 'MoarVM', 'MoarVM'), | 
| 51 |  |  |  |  |  |  | nqp    => get_git_url($GIT_PROTO, 'github.com', 'perl6',  'nqp'), | 
| 52 |  |  |  |  |  |  | zef    => get_git_url($GIT_PROTO, 'github.com', 'ugexe',  'zef'), | 
| 53 |  |  |  |  |  |  | ); | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | our %impls = ( | 
| 56 |  |  |  |  |  |  | jvm => { | 
| 57 |  |  |  |  |  |  | name      => "jvm", | 
| 58 |  |  |  |  |  |  | weight    => 20, | 
| 59 |  |  |  |  |  |  | configure => "$PERL5 Configure.pl --backends=jvm --gen-nqp --make-install", | 
| 60 |  |  |  |  |  |  | need_repo => ['rakudo', 'nqp'], | 
| 61 |  |  |  |  |  |  | }, | 
| 62 |  |  |  |  |  |  | moar => { | 
| 63 |  |  |  |  |  |  | name      => "moar", | 
| 64 |  |  |  |  |  |  | weight    => 30, | 
| 65 |  |  |  |  |  |  | configure => "$PERL5 Configure.pl --backends=moar --gen-moar --make-install", | 
| 66 |  |  |  |  |  |  | need_repo => ['rakudo', 'nqp', 'MoarVM'], | 
| 67 |  |  |  |  |  |  | }, | 
| 68 |  |  |  |  |  |  | 'moar-blead' => { | 
| 69 |  |  |  |  |  |  | name      => "moar-blead", | 
| 70 |  |  |  |  |  |  | weight    => 35, | 
| 71 |  |  |  |  |  |  | configure => "$PERL5 Configure.pl --backends=moar --gen-moar=master --gen-nqp=main --make-install", | 
| 72 |  |  |  |  |  |  | need_repo => ['rakudo', 'nqp', 'MoarVM'], | 
| 73 |  |  |  |  |  |  | }, | 
| 74 |  |  |  |  |  |  | ); | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | sub available_backends { | 
| 77 | 0 |  |  | 0 | 0 |  | map {$_->{name}} sort {$a->{weight} <=> $b->{weight}} values %impls; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | 1; | 
| 82 |  |  |  |  |  |  |  |