File Coverage

alienfile
Criterion Covered Total %
statement 9 12 75.0
branch 0 2 0.0
condition n/a
subroutine 3 4 75.0
pod n/a
total 12 18 66.6


line stmt bran cond sub pod time code
1 1     1   205877 use alienfile;
  1         3  
  1         6  
2              
3 1     1   141 use Path::Tiny;
  1         1  
  1         32  
4 1     1   6 use File::Which qw(which);
  1         1  
  1         409  
5              
6             plugin 'Probe::CommandLine' => (
7             command => 'plantuml',
8             args => [ '-version' ],
9             match => qr/PlantUML/,
10             version => qr/PlantUML version ([0-9\.]+)/,
11             );
12              
13             sub find_jar_file {
14 0     0     my $plantuml = path(scalar which('plantuml'));
15 0 0         if( my ($jar_file) = $plantuml->slurp_utf8 =~ qr/-jar\s+(\S+\.jar)/s ) {
16 0           return $jar_file;
17             }
18             }
19              
20             meta->around_hook( probe => sub {
21             my $orig = shift;
22             my ($build) = @_;
23             my $install_type = $orig->(@_);
24              
25             my $jar_file = find_jar_file();
26             if( defined $jar_file and -f $jar_file ) {
27             return 'system';
28             } else {
29             $build->log('Could not find JAR file');
30             return 'share';
31             }
32             });
33              
34             sys {
35             gather sub {
36             my ($build) = @_;
37             $build->runtime_prop->{jar_file} = find_jar_file();
38             };
39             };
40              
41              
42             share {
43             # TODO
44             # - choose license to install
45             # - build from source
46             # - depend on Java
47             plugin 'Download::GitHub' => (
48             github_user => 'plantuml',
49             github_repo => 'plantuml',
50             asset => 1,
51             asset_name => qr/^plantuml-([0-9\.]+)\.jar$/,
52             asset_format => 'none',
53             );
54             plugin 'Extract::File';
55             plugin 'Build::Copy';
56              
57             gather sub {
58             my ($build) = @_;
59             my $jar_basename = path( $build->install_prop->{download} )->basename;
60             $build->runtime_prop->{jar_file} = $jar_basename;
61             };
62             }