line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Scaffolder::Puppet::Command; |
2
|
|
|
|
|
|
|
$App::Scaffolder::Puppet::Command::VERSION = '0.004000'; |
3
|
3
|
|
|
3
|
|
106030
|
use parent qw(App::Scaffolder::Command); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
19
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Base class for App::Scaffolder::Puppet commands |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
114493
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
60
|
|
8
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
84
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
18
|
use File::Spec::Functions qw(catdir); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
166
|
|
11
|
3
|
|
|
3
|
|
22
|
use MRO::Compat; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
57
|
|
12
|
3
|
|
|
3
|
|
16
|
use Path::Class::Dir; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
1443
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_target { |
16
|
5
|
|
|
5
|
1
|
6429
|
my ($self, $opt) = @_; |
17
|
5
|
|
66
|
|
|
31
|
my $target = $opt->target() || ( |
18
|
|
|
|
|
|
|
$opt->name() =~ m{::}x |
19
|
|
|
|
|
|
|
? '.' |
20
|
|
|
|
|
|
|
: $opt->name() |
21
|
|
|
|
|
|
|
); |
22
|
5
|
|
|
|
|
439
|
return Path::Class::Dir->new($target); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_variables { |
28
|
5
|
|
|
5
|
1
|
2181
|
my ($self, $opt) = @_; |
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
29
|
my @name_parts = split(/::/x, $opt->name()); |
31
|
5
|
|
|
|
|
229
|
my (undef, @subname_parts) = @name_parts; |
32
|
5
|
|
66
|
|
|
39
|
my $package = $opt->package() || $opt->name(); |
33
|
|
|
|
|
|
|
return { |
34
|
5
|
|
50
|
|
|
315
|
name => scalar $opt->name(), |
|
|
|
100
|
|
|
|
|
35
|
|
|
|
|
|
|
nameparts => \@name_parts, |
36
|
|
|
|
|
|
|
namepartsjoined => join('_', @name_parts), |
37
|
|
|
|
|
|
|
namepartspath => catdir(@name_parts) || '', |
38
|
|
|
|
|
|
|
subnameparts => \@subname_parts, |
39
|
|
|
|
|
|
|
subnamepartsjoined => join('_', @subname_parts), |
40
|
|
|
|
|
|
|
subnamepartspath => catdir(@subname_parts) || '', |
41
|
|
|
|
|
|
|
package => $package, |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_dist_name { |
48
|
4
|
|
|
4
|
1
|
254
|
return 'App-Scaffolder-Puppet'; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_options { |
54
|
2
|
|
|
2
|
1
|
65546
|
my ($class) = @_; |
55
|
|
|
|
|
|
|
return ( |
56
|
2
|
|
|
|
|
27
|
[ 'name|n=s' => 'Name of the new Puppet module/class that should be created' ], |
57
|
|
|
|
|
|
|
[ 'package|p=s' => 'Name of a package that should be available in templates ' |
58
|
|
|
|
|
|
|
. '(defaults to the value of the --name parameter)' ], |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub validate_args { |
64
|
2
|
|
|
2
|
1
|
5524
|
my ($self, $opt, $args) = @_; |
65
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
19
|
$self->next::method($opt, $args); |
67
|
2
|
50
|
33
|
|
|
152
|
unless ($self->contains_base_args($opt) || $opt->name()) { |
68
|
0
|
|
|
|
|
0
|
$self->usage_error("Parameter 'name' required"); |
69
|
|
|
|
|
|
|
} |
70
|
2
|
|
|
|
|
41
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_extra_template_dirs { |
76
|
3
|
|
|
3
|
1
|
3873
|
my ($self, $command) = @_; |
77
|
|
|
|
|
|
|
|
78
|
3
|
|
|
|
|
18
|
my @sub_path = ('etc', 'puppet', 'scaffolder_templates', $command); |
79
|
3
|
50
|
|
|
|
29
|
my @extra_template_dirs = grep { -d $_ && -r $_ } ( |
|
6
|
|
|
|
|
575
|
|
80
|
|
|
|
|
|
|
Path::Class::Dir->new('', @sub_path), |
81
|
|
|
|
|
|
|
Path::Class::Dir->new('', 'usr', 'local', @sub_path), |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return ( |
85
|
3
|
|
|
|
|
201
|
$self->next::method($command), |
86
|
|
|
|
|
|
|
@extra_template_dirs, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |