line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OTRS::OPM::Installer::Utils::Config; |
2
|
|
|
|
|
|
|
$OTRS::OPM::Installer::Utils::Config::VERSION = '0.02'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Read config file for OTRS::OPM::Installer |
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
276905
|
use strict; |
|
14
|
|
|
|
|
69
|
|
|
14
|
|
|
|
|
446
|
|
6
|
14
|
|
|
14
|
|
85
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
428
|
|
7
|
|
|
|
|
|
|
|
8
|
14
|
|
|
14
|
|
161
|
use Carp qw(croak); |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
709
|
|
9
|
14
|
|
|
14
|
|
136
|
use File::Basename; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
762
|
|
10
|
14
|
|
|
14
|
|
1692
|
use File::HomeDir; |
|
14
|
|
|
|
|
22187
|
|
|
14
|
|
|
|
|
724
|
|
11
|
14
|
|
|
14
|
|
92
|
use File::Spec; |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
296
|
|
12
|
14
|
|
|
14
|
|
1676
|
use Moo; |
|
14
|
|
|
|
|
45816
|
|
|
14
|
|
|
|
|
84
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has rc_config => ( is => 'ro', lazy => 1, default => \&_rc_config ); |
15
|
|
|
|
|
|
|
has conf => ( is => 'ro' ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _rc_config { |
18
|
4
|
|
|
4
|
|
7227
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
30
|
my $dot_file = File::Spec->catfile( |
21
|
|
|
|
|
|
|
File::HomeDir->my_home, |
22
|
|
|
|
|
|
|
'.opminstaller.rc' |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
4
|
100
|
100
|
|
|
312
|
if ( $self->conf && -f $self->conf ) { |
|
|
100
|
|
|
|
|
|
26
|
2
|
|
|
|
|
6
|
$dot_file = $self->conf; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif ( $self->conf ) { |
29
|
1
|
|
|
|
|
158
|
croak 'Config file ' . $self->conf . ' does not exist'; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
7
|
my %config; |
33
|
3
|
50
|
33
|
|
|
107
|
if ( -f $dot_file && open my $fh, '<', $dot_file ) { |
34
|
3
|
|
|
|
|
48
|
while ( my $line = <$fh> ) { |
35
|
9
|
|
|
|
|
19
|
chomp $line; |
36
|
9
|
50
|
|
|
|
25
|
next if $line =~ m{\A\s*\#}; |
37
|
9
|
50
|
|
|
|
29
|
next if $line =~ m{\A\s*\z}; |
38
|
|
|
|
|
|
|
|
39
|
9
|
|
|
|
|
41
|
my ($key, $value) = split /\s*=\s*/, $line; |
40
|
9
|
|
|
|
|
26
|
$key = lc $key; |
41
|
|
|
|
|
|
|
|
42
|
9
|
100
|
|
|
|
36
|
if ( $key eq 'repository' ) { |
|
|
50
|
|
|
|
|
|
43
|
6
|
|
|
|
|
12
|
push @{ $config{$key} }, $value; |
|
6
|
|
|
|
|
27
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ( $key eq 'otrs_path' ) { |
46
|
3
|
100
|
|
|
|
23
|
if ( !File::Spec->file_name_is_absolute( $value ) ) { |
47
|
1
|
|
|
|
|
24
|
my $dir = dirname $dot_file; |
48
|
1
|
|
|
|
|
18
|
$value = File::Spec->rel2abs( |
49
|
|
|
|
|
|
|
File::Spec->catdir( $dir, $value ), |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
21
|
$config{$key} = $value; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
|
|
|
|
0
|
$config{$key} = $value; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
29
|
return \%config; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
OTRS::OPM::Installer::Utils::Config - Read config file for OTRS::OPM::Installer |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 0.02 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Renee Baecker <reneeb@cpan.org> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This software is Copyright (c) 2017 by Renee Baecker. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is free software, licensed under: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |