BundleDeps/Platypus.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 70 CC 7 SCAR 27.1
CC
7
Cov
0%
build_platypus_app
30.0
new
12.0
bundle
2.0
CRAP 15.1
1 package App::BundleDeps::Platypus;
2 use strict;
3 use warnings;
4 use base qw(App::BundleDeps);
5 use File::Path qw(rmtree);
6  
7 foreach my $elem qw(app author icon identifier platypus resources default_resources script version background) {
8 my $str = "sub $elem { my (\$self, \@args) = \@_; my \$ret = \$self->{$elem}; \$self->{$elem} = shift \@args if \@args; return \$ret }";
9 eval $str;
10 die if $@;
11 }
12  
13 sub new {
14 my ($class, @args) = @_;
15  
16 my $self = $class->SUPER::new(
17 author => $ENV{USER},
18 icon => 'appIcon.icns',
19 resources => [],
20 background => 0,
21 @args,
22 default_resources => [ 'lib', 'extlib' ]
23 );
24  
25 if (! $self->app) {
26 my $script = $self->script;
27 $script =~ s/\.plx?$//;
28 $self->app( join " ", map ucfirst, split /[ _\-]/, $script);
29 }
30  
31 if (! $self->identifier) {
32 my $app = $self->app;
33 $app =~ tr/ //d;
34 $self->identifier( "com.example." . $self->author . ".app");
35 }
36 return $self;
37 }
38  
39 sub bundle {
40 my $self = shift;
41 $self->SUPER::bundle();
42 $self->build_platypus_app();
43 }
44  
45 sub build_platypus_app {
46 my $self = shift;
47  
48 my $app_path = $self->app . ".app";
49 if (-e $app_path) {
50 rmtree($app_path);
51 }
52  
53 my $output =`platypus -v`;
54 if ($output !~ /version (\d+\.\d+) by/) {
55 print STDERR "Could not get version from platypus: Did you install the command line utility?\n";
56 return;
57 }
58 my $version = $1;
59  
60 print "Building Mac application ", $self->app, ".app ...";
61 system "platypus",
62 "-a", $self->app, "-o", 'None', "-u", $self->author,
63 "-p", $^X, "-s", '????',
64 (-e $self->icon ? ("-i", $self->icon) : ()),
65 "-I", $self->identifier,
66 "-N", "APP_BUNDLER=Platypus-4.0",
67 (map { ("-f", "$_") } @{$self->resources}, @{$self->default_resources}),
68 "-c", $self->script,
69 ($self->background ? "-B" : ()),
70 "-V", $self->version,
71 File::Spec->catfile( File::Spec->curdir, $app_path );
72 }
73  
74  
75 1;
76  
77 __END__