File Coverage

blib/lib/App/Rakubrew/Variables.pm
Criterion Covered Total %
statement 29 30 96.6
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod 0 2 0.0
total 40 44 90.9


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 15     15   99 use strict;
  15         27  
  15         595  
7 15     15   67 use warnings;
  15         58  
  15         1044  
8 15     15   300 use 5.010;
  15         53  
9              
10 15     15   770 use FindBin qw($RealBin);
  15         1335  
  15         2381  
11 15     15   97 use File::Spec::Functions qw(catfile catdir updir);
  15         26  
  15         1239  
12 15     15   81 use Cwd qw(abs_path);
  15         41  
  15         832  
13 15     15   8308 use File::HomeDir;
  15         97389  
  15         1194  
14 15     15   7298 use App::Rakubrew::Config;
  15         105  
  15         12221  
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 60     60 0 127 my ($protocol, $host, $user, $project) = @_;
41 60 50       122 if ($protocol eq "ssh") {
42 0         0 return "git\@${host}:${user}/${project}.git";
43             } else {
44 60         246 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', 'Raku', '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 2     2 0 19 map {$_->{name}} sort {$a->{weight} <=> $b->{weight}} values %impls;
  6         26  
  4         18  
78             }
79              
80              
81             1;
82