File Coverage

blib/lib/App/Rakubrew/Variables.pm
Criterion Covered Total %
statement 26 30 86.6
branch 1 2 50.0
condition n/a
subroutine 9 10 90.0
pod 0 2 0.0
total 36 44 81.8


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   20 use strict;
  3         8  
  3         89  
7 3     3   15 use warnings;
  3         6  
  3         102  
8 3     3   56 use 5.010;
  3         11  
9              
10 3     3   438 use FindBin qw($RealBin);
  3         1015  
  3         326  
11 3     3   23 use File::Spec::Functions qw(catfile catdir updir);
  3         7  
  3         199  
12 3     3   19 use Cwd qw(abs_path);
  3         15  
  3         140  
13 3     3   1489 use File::HomeDir;
  3         17273  
  3         160  
14 3     3   1220 use App::Rakubrew::Config;
  3         9  
  3         1915  
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 25 my ($protocol, $host, $user, $project) = @_;
41 12 50       23 if ($protocol eq "ssh") {
42 0         0 return "git\@${host}:${user}/${project}.git";
43             } else {
44 12         52 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=main --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