line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archer::Plugin; |
2
|
5
|
|
|
5
|
|
2830
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
155
|
|
3
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
109
|
|
4
|
5
|
|
|
5
|
|
25
|
use Archer; |
|
5
|
|
|
|
|
137
|
|
|
5
|
|
|
|
|
56
|
|
5
|
5
|
|
|
5
|
|
7326
|
use Template; |
|
5
|
|
|
|
|
141262
|
|
|
5
|
|
|
|
|
53
|
|
6
|
5
|
|
|
5
|
|
4896
|
use String::CamelCase qw//; |
|
5
|
|
|
|
|
2833
|
|
|
5
|
|
|
|
|
108
|
|
7
|
5
|
|
|
5
|
|
33
|
use Path::Class; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
322
|
|
8
|
5
|
|
|
5
|
|
27
|
use Carp; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
2834
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
33
|
|
|
33
|
0
|
55
|
my ( $class, $args ) = @_; |
12
|
33
|
|
|
|
|
253
|
bless { %$args }, $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub log { |
16
|
8
|
|
|
8
|
0
|
110
|
my $self = shift; |
17
|
8
|
|
|
|
|
44
|
Archer->context->log( @_ ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub templatize { |
21
|
2
|
|
|
2
|
0
|
6
|
my ( $self, $cmd ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $vars = { |
24
|
|
|
|
|
|
|
config => $self->{ config }, |
25
|
|
|
|
|
|
|
project => $self->{ project }, |
26
|
|
|
|
|
|
|
l_project => $self->l_project, |
27
|
|
|
|
|
|
|
work_dir => Archer->context->{ config }->{ global }->{ work_dir }, |
28
|
|
|
|
|
|
|
dest_dir => Archer->context->{ config }->{ global }->{ dest_dir }, |
29
|
|
|
|
|
|
|
server => $self->{ server }, |
30
|
|
|
|
|
|
|
user => $ENV{ USER }, |
31
|
2
|
|
|
|
|
17
|
}; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
48
|
my $tt = Template->new; |
34
|
2
|
50
|
|
|
|
550322
|
$tt->process( \$cmd, $vars, \my $out ) |
35
|
|
|
|
|
|
|
or $self->log( 'error' => 'Template Error: ' . $tt->error ); |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
164176
|
$out; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub detach { |
41
|
1
|
|
|
1
|
0
|
61
|
my ( $self, $msg ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
959
|
croak "$msg\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# FIXME: so bad...following method... |
47
|
|
|
|
|
|
|
sub l_project { |
48
|
2
|
|
|
2
|
0
|
6
|
my ( $self, ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
8
|
my $work_dir = Archer->context->{ config }->{ global }->{ work_dir }; |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
13
|
my $lc = String::CamelCase::decamelize( $self->{ project } ); |
53
|
2
|
50
|
|
|
|
181
|
if ( -e file( $work_dir, $self->{ project }, $lc )->stringify ) { |
54
|
0
|
|
|
|
|
0
|
return $lc; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
2
|
|
|
|
|
640
|
return lc Archer->context->{ project }; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub check_recipe { |
62
|
0
|
|
|
0
|
0
|
|
my ( $self, $recipe_name, $altern_path ) = @_; |
63
|
0
|
|
|
|
|
|
my ( $f, $path ); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$f = File::Util->new; |
66
|
0
|
|
|
|
|
|
$path = File::Spec->catfile( $FindBin::Bin, 'assets', 'recipe', |
67
|
|
|
|
|
|
|
$recipe_name ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# check first in assets |
70
|
0
|
0
|
|
|
|
|
if ( $f->existent( $path ) ) { |
71
|
0
|
|
|
|
|
|
return $f->load_file( $path ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# if there is another path for recipe in the config, check this one |
75
|
0
|
|
|
|
|
|
$path = File::Spec->catfile( $altern_path, $recipe_name ); |
76
|
0
|
0
|
|
|
|
|
if ( $f->existent( $path ) ) { |
77
|
0
|
|
|
|
|
|
return $f->load_file( $path ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# fail |
81
|
0
|
|
|
|
|
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |