File Coverage

blib/lib/Rex/Apache/Build/Base.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4             # vim: set ts=3 sw=3 tw=0:
5             # vim: set expandtab:
6            
7             package Rex::Apache::Build::Base;
8              
9 1     1   1167 use strict;
  1         2  
  1         39  
10 1     1   6 use warnings;
  1         2  
  1         27  
11              
12 1     1   5 use Data::Dumper;
  1         3  
  1         51  
13 1     1   433 use Rex::Commands::Gather;
  0            
  0            
14              
15             sub new {
16             my $that = shift;
17             my $proto = ref($that) || $that;
18             my $self = { @_ };
19              
20             my %sys_info = get_system_information();
21              
22             $self->{maintainer} ||= ($ENV{USER} || "unknown");
23             $self->{arch} ||= $sys_info{architecture},
24             $self->{section} ||= "none";
25             $self->{url} ||= "http://example.tld/";
26             $self->{version} ||= "1.0";
27             $self->{description} ||= "No Description";
28             $self->{target} ||= "linux";
29             $self->{depends} ||= [];
30             $self->{provides} ||= [];
31             $self->{conflicts} ||= [];
32             $self->{config_files} ||= [];
33              
34             $self->{exclude} ||= [];
35             push(@{ $self->{exclude} }, qr{^Rexfile$}, qr{^Rexfile\.lock$}, qr{^\.git}, qr{^\.svn}, qr{.*~$}, qr{\.sw[a-z]$}, qr{^tmp$}, qr{\.cache$});
36              
37             $self->{source} ||= ".";
38              
39              
40             bless($self, $proto);
41              
42             return $self;
43             }
44              
45             for my $name (qw/
46             path
47             source
48             release
49             epoch
50             version
51             vendor
52             license
53             depends
54             conflicts
55             provides
56             arch
57             target
58             description
59             section
60             url
61             post_install
62             pre_install
63             post_uninstall
64             pre_uninstall
65             exclude
66             maintainer
67             priority
68             name
69             config_files
70             file_user
71             file_group
72             /) {
73             no strict 'refs';
74             *{__PACKAGE__ . "::$name"} = sub {
75             my ($self, $data) = @_;
76              
77             if($data) {
78             $self->{$name} = $data;
79             }
80              
81             $self->{$name};
82              
83             };
84             use strict;
85             }
86              
87             sub prefix {
88             my ($self, $prefix) = @_;
89              
90             if($prefix) {
91             $self->{prefix} = $prefix;
92             }
93              
94             return $self->{prefix} || $self->{path};
95             }
96              
97             sub build {
98             my ($self, $target) = @_;
99             die("Must be implemented by Class.");
100             }
101              
102             1;